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
This commit is contained in:
parent
30a4a798e5
commit
8f407c7b99
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user