[ddc] Optimize checks for object constructor

Flipped the ordering of the equality operation so that the compiler
can see it is being dispatched to a string literal and can generate
a faster check.

Change-Id: I5c2f6b123ebe0f6cb81efba94fe4bf81168bec74
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/317261
Reviewed-by: Mark Zhou <markzipan@google.com>
Commit-Queue: Nicholas Shahan <nshahan@google.com>
This commit is contained in:
Nicholas Shahan 2023-08-01 03:49:21 +00:00 committed by Commit Queue
parent d9363a6639
commit 858badcf50
2 changed files with 3 additions and 3 deletions

View file

@ -35,7 +35,7 @@ void _copyMembers(@notNull Object to, @notNull Object from) {
var names = getOwnNamesAndSymbols(from);
for (int i = 0, n = JS('!', '#.length', names); i < n; ++i) {
String name = JS('', '#[#]', names, i);
if (name == 'constructor') continue;
if ('constructor' == name) continue;
_copyMember(to, from, name);
}
}
@ -463,7 +463,7 @@ void _installPropertiesForObject(jsProto) {
var names = getOwnPropertyNames(coreObjProto);
for (int i = 0, n = JS('!', '#.length', names); i < n; ++i) {
var name = JS<String>('!', '#[#]', names, i);
if (name == 'constructor') continue;
if ('constructor' == name) continue;
var desc = getOwnPropertyDescriptor(coreObjProto, name);
defineProperty(jsProto, JS('', '#.#', dartx, name), desc);
}

View file

@ -64,7 +64,7 @@ safeGetOwnProperty(obj, name) {
copyTheseProperties(to, from, names) {
for (int i = 0, n = JS('!', '#.length', names); i < n; ++i) {
var name = JS('', '#[#]', names, i);
if (name == 'constructor') continue;
if ('constructor' == name) continue;
copyProperty(to, from, name);
}
return to;