From 8f407c7b99d78741d8386403c098cbd7c3575baa Mon Sep 17 00:00:00 2001 From: "adamk@chromium.org" Date: Mon, 25 Feb 2013 19:44:21 +0000 Subject: [PATCH] Move extensibility check to the top of Object.isFrozen/Object.isSealed This speeds up isFrozen/isSealed checks on "normal" objects without slowing down checks on frozen/sealed objects. Though this ordering is not what ES5 specifies, the difference is not observable (especially since the code bails out if the passed-in object is a proxy). Review URL: https://codereview.chromium.org/12340008 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13726 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/v8natives.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/v8natives.js b/src/v8natives.js index 8473dd1596..9a8e4e37d8 100644 --- a/src/v8natives.js +++ b/src/v8natives.js @@ -1246,16 +1246,16 @@ function ObjectIsSealed(obj) { if (%IsJSProxy(obj)) { return false; } + if (%IsExtensible(obj)) { + return false; + } var names = ObjectGetOwnPropertyNames(obj); for (var i = 0; i < names.length; i++) { var name = names[i]; var desc = GetOwnProperty(obj, name); if (desc.isConfigurable()) return false; } - if (!ObjectIsExtensible(obj)) { - return true; - } - return false; + return true; } @@ -1267,6 +1267,9 @@ function ObjectIsFrozen(obj) { if (%IsJSProxy(obj)) { return false; } + if (%IsExtensible(obj)) { + return false; + } var names = ObjectGetOwnPropertyNames(obj); for (var i = 0; i < names.length; i++) { var name = names[i]; @@ -1274,10 +1277,7 @@ function ObjectIsFrozen(obj) { if (IsDataDescriptor(desc) && desc.isWritable()) return false; if (desc.isConfigurable()) return false; } - if (!ObjectIsExtensible(obj)) { - return true; - } - return false; + return true; }