mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:48:10 +00:00
LibJS+AK: Use Vector<u16, 1> for UTF-16 string storage
It's very common to encounter single-character strings in JavaScript on the web. We can make such strings significantly lighter by having a 1-character inline capacity on the Vectors.
This commit is contained in:
parent
ae0bdda86e
commit
024367d82e
7 changed files with 27 additions and 26 deletions
|
@ -140,7 +140,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_char_code)
|
|||
// 22.1.2.2 String.fromCodePoint ( ...codePoints ), https://tc39.es/ecma262/#sec-string.fromcodepoint
|
||||
JS_DEFINE_NATIVE_FUNCTION(StringConstructor::from_code_point)
|
||||
{
|
||||
Vector<u16> string;
|
||||
Vector<u16, 1> string;
|
||||
string.ensure_capacity(vm.argument_count()); // This will be an under-estimate if any code point is > 0xffff.
|
||||
|
||||
for (size_t i = 0; i < vm.argument_count(); ++i) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue