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/MarkupGenerator.cpp | |
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/MarkupGenerator.cpp')
-rw-r--r-- | Userland/Libraries/LibJS/MarkupGenerator.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibJS/MarkupGenerator.cpp b/Userland/Libraries/LibJS/MarkupGenerator.cpp index e4af4f7021..0da123a3ff 100644 --- a/Userland/Libraries/LibJS/MarkupGenerator.cpp +++ b/Userland/Libraries/LibJS/MarkupGenerator.cpp @@ -144,8 +144,8 @@ void MarkupGenerator::date_to_html(const Object& date, StringBuilder& html_outpu void MarkupGenerator::error_to_html(const Object& object, StringBuilder& html_output, HashTable<Object*>&) { - auto name = object.get_without_side_effects("name").value_or(JS::js_undefined()); - auto message = object.get_without_side_effects("message").value_or(JS::js_undefined()); + auto name = object.get_without_side_effects(PropertyName("name")).value_or(JS::js_undefined()); + auto message = object.get_without_side_effects(PropertyName("message")).value_or(JS::js_undefined()); if (name.is_accessor() || name.is_native_property() || message.is_accessor() || message.is_native_property()) { html_output.append(wrap_string_in_style(JS::Value(&object).to_string_without_side_effects(), StyleType::Invalid)); } else { |