From 5eef07d232fc179f0640bbb8cff575cd239c4d65 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Jun 2021 18:59:07 +0200 Subject: 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. --- Userland/Libraries/LibJS/MarkupGenerator.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Userland/Libraries/LibJS/MarkupGenerator.cpp') 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&) { - 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 { -- cgit v1.2.3