mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-15 14:51:52 +00:00
LibJS: Make Optional<StringTableIndex> use less space
We can use the index's invalid state to signal an empty optional. This makes Optional<StringTableIndex> 4 bytes instead of 8, shrinking every bytecode instruction that uses these.
This commit is contained in:
parent
f1a54ef281
commit
42cc481091
Notes:
github-actions[bot]
2025-04-06 00:06:34 +00:00
Author: https://github.com/awesomekling
Commit: 42cc481091
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4243
3 changed files with 110 additions and 6 deletions
|
@ -11,12 +11,12 @@ namespace JS::Bytecode {
|
|||
StringTableIndex StringTable::insert(String string)
|
||||
{
|
||||
m_strings.append(move(string));
|
||||
return m_strings.size() - 1;
|
||||
return { static_cast<u32>(m_strings.size() - 1) };
|
||||
}
|
||||
|
||||
String const& StringTable::get(StringTableIndex index) const
|
||||
{
|
||||
return m_strings[index.value()];
|
||||
return m_strings[index.value];
|
||||
}
|
||||
|
||||
void StringTable::dump() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue