Revert "LibJS: Use HashMap::ensure() in VM string cache helpers"

This reverts commit 5810ddf339.

Appears to have introduced flakiness on WPT.
This commit is contained in:
Andreas Kling 2025-10-06 12:15:23 +02:00
commit 7a2fe53c65
Notes: github-actions[bot] 2025-10-06 10:18:09 +00:00
2 changed files with 13 additions and 10 deletions

View file

@ -35,9 +35,12 @@ GC::Ref<PrimitiveString> PrimitiveString::create(VM& vm, Utf16String const& stri
}
auto& string_cache = vm.utf16_string_cache();
return *string_cache.ensure(string, [&] {
return vm.heap().allocate<PrimitiveString>(string);
});
if (auto it = string_cache.find(string); it != string_cache.end())
return *it->value;
auto new_string = vm.heap().allocate<PrimitiveString>(string);
string_cache.set(move(string), new_string);
return *new_string;
}
GC::Ref<PrimitiveString> PrimitiveString::create(VM& vm, Utf16View const& string)
@ -64,9 +67,9 @@ GC::Ref<PrimitiveString> PrimitiveString::create(VM& vm, String const& string)
if (auto it = string_cache.find(string); it != string_cache.end())
return *it->value;
return string_cache.ensure(string, [&] {
return vm.heap().allocate<PrimitiveString>(string);
});
auto new_string = vm.heap().allocate<PrimitiveString>(string);
string_cache.set(move(string), new_string);
return *new_string;
}
GC::Ref<PrimitiveString> PrimitiveString::create(VM& vm, StringView string)