mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-26 22:38:51 +00:00
LibJS: Use String and move semantics in Bytecode::StringTable
Avoid creating new AK::String objects when we already have one.
This commit is contained in:
parent
3117182c2e
commit
13f04e37e5
Notes:
sideshowbarker
2024-07-18 01:56:44 +09:00
Author: https://github.com/awesomekling
Commit: 13f04e37e5
3 changed files with 5 additions and 5 deletions
|
@ -8,13 +8,13 @@
|
|||
|
||||
namespace JS::Bytecode {
|
||||
|
||||
StringTableIndex StringTable::insert(StringView string)
|
||||
StringTableIndex StringTable::insert(String string)
|
||||
{
|
||||
for (size_t i = 0; i < m_strings.size(); i++) {
|
||||
if (m_strings[i] == string)
|
||||
return i;
|
||||
}
|
||||
m_strings.append(string);
|
||||
m_strings.append(move(string));
|
||||
return m_strings.size() - 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue