diff options
author | Andreas Kling <kling@serenityos.org> | 2021-06-13 18:59:07 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-06-13 19:11:29 +0200 |
commit | 5eef07d232fc179f0640bbb8cff575cd239c4d65 (patch) | |
tree | f2793ff33530445dcf110b42d0013636ee52c11c /Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h | |
parent | 53a8a11973cb4be1dc688fc245775540630bf87d (diff) | |
download | serenity-5eef07d232fc179f0640bbb8cff575cd239c4d65.zip |
LibJS: Avoid lots of string-to-int during global object construction
We were doing a *lot* of string-to-int conversion while creating a new
global object. This happened because Object::put() would try to convert
the property name (string) to an integer to see if it refers to an
indexed property.
Sidestep this issue by using PropertyName for the CommonPropertyNames
struct on VM (vm.names.foo), and giving PropertyName a flag that tells
us whether it's a string that *may be* a number.
All CommonPropertyNames are set up so they are known to not be numbers.
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h index d17dd77527..b8c88aed25 100644 --- a/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h +++ b/Userland/Libraries/LibJS/Runtime/CommonPropertyNames.h @@ -295,18 +295,18 @@ namespace JS { P(writable) struct CommonPropertyNames { - FlyString catch_ { "catch" }; - FlyString delete_ { "delete" }; - FlyString for_ { "for" }; - FlyString return_ { "return" }; - FlyString throw_ { "throw" }; -#define __ENUMERATE(x) FlyString x { #x }; + PropertyName catch_ { "catch", PropertyName::StringMayBeNumber::No }; + PropertyName delete_ { "delete", PropertyName::StringMayBeNumber::No }; + PropertyName for_ { "for", PropertyName::StringMayBeNumber::No }; + PropertyName return_ { "return", PropertyName::StringMayBeNumber::No }; + PropertyName throw_ { "throw", PropertyName::StringMayBeNumber::No }; +#define __ENUMERATE(x) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; ENUMERATE_STANDARD_PROPERTY_NAMES(__ENUMERATE) #undef __ENUMERATE -#define __JS_ENUMERATE(x, a, b, c, t) FlyString x { #x }; +#define __JS_ENUMERATE(x, a, b, c, t) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; JS_ENUMERATE_BUILTIN_TYPES #undef __JS_ENUMERATE -#define __JS_ENUMERATE(x, a) FlyString x { #x }; +#define __JS_ENUMERATE(x, a) PropertyName x { #x, PropertyName::StringMayBeNumber::No }; JS_ENUMERATE_WELL_KNOWN_SYMBOLS #undef __JS_ENUMERATE }; |