mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 10:49:00 +00:00
[dartdevc] Using hasOwnProperty instead of getOwnPropertyDescriptor.value.
getOwnPropertyDescriptor is significantly slower than hasOwnProperty, and we didn't seem to be using any behavior specific to the descriptor besides the value. Change-Id: I3329177ee78a5ca823e554dd4f7b0bd26e1d5be0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138331 Commit-Queue: Mark Zhou <markzipan@google.com> Reviewed-by: Sigmund Cherem <sigmund@google.com>
This commit is contained in:
parent
6f4876849b
commit
c426b60da4
2 changed files with 12 additions and 4 deletions
|
@ -53,9 +53,13 @@ Iterable getOwnNamesAndSymbols(obj) {
|
|||
return JS('', '#.concat(#)', names, symbols);
|
||||
}
|
||||
|
||||
/// Returns the value of field `name` on `obj`.
|
||||
///
|
||||
/// We use this instead of obj[name] since obj[name] checks the entire
|
||||
/// prototype chain instead of just `obj`.
|
||||
safeGetOwnProperty(obj, name) {
|
||||
var desc = getOwnPropertyDescriptor(obj, name);
|
||||
if (desc != null) return JS('', '#.value', desc);
|
||||
if (JS<bool>('!', '#.hasOwnProperty(#)', obj, name))
|
||||
return JS<Object>('', '#[#]', obj, name);
|
||||
}
|
||||
|
||||
/// Defines a lazy static field.
|
||||
|
|
|
@ -51,9 +51,13 @@ Iterable getOwnNamesAndSymbols(obj) {
|
|||
return JS('', '#.concat(#)', names, symbols);
|
||||
}
|
||||
|
||||
/// Returns the value of field `name` on `obj`.
|
||||
///
|
||||
/// We use this instead of obj[name] since obj[name] checks the entire
|
||||
/// prototype chain instead of just `obj`.
|
||||
safeGetOwnProperty(obj, name) {
|
||||
var desc = getOwnPropertyDescriptor(obj, name);
|
||||
if (desc != null) return JS('', '#.value', desc);
|
||||
if (JS<bool>('!', '#.hasOwnProperty(#)', obj, name))
|
||||
return JS<Object>('', '#[#]', obj, name);
|
||||
}
|
||||
|
||||
/// Defines a lazy static field.
|
||||
|
|
Loading…
Reference in a new issue