mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 09:45:06 +02:00
LibJS: Add number-to-string cache for numbers < 1000
We are often forced to convert numbers to strings inside LibJS, e.g when iterating over the property names of an array, but it's also just a very common operation in general. This patch adds a 1000-entry string cache for the numbers 0-999 since those appear to be by far the most common ones we convert.
This commit is contained in:
committed by
Andreas Kling
parent
0c3f113e05
commit
b691f4c7af
Notes:
github-actions[bot]
2025-10-05 19:45:30 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/b691f4c7afb Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6401
@@ -245,7 +245,7 @@ JS::ThrowCompletionOr<GC::RootVector<JS::Value>> WindowProxy::internal_own_prope
|
||||
// 5. Repeat while index < maxProperties,
|
||||
for (size_t i = 0; i < max_properties; ++i) {
|
||||
// 1. Add ! ToString(index) as the last element of keys.
|
||||
keys.append(JS::PrimitiveString::create(vm, ByteString::number(i)));
|
||||
keys.append(JS::PrimitiveString::create_from_unsigned_integer(vm, i));
|
||||
|
||||
// 2. Increment index by 1.
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user