mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-12 20:11:51 +00:00
LibJS: Cache string constants in Generator::add_constant
This mirrors the existing caching logic for int32 constants. Avoids duplication of string constants in m_constants which could result in stack overflows for large scripts with a lot of similar strings.
This commit is contained in:
parent
9bf836e6c4
commit
3ba6d129df
Notes:
github-actions[bot]
2025-06-01 16:27:18 +00:00
Author: https://github.com/jlebras 🔰
Commit: 3ba6d129df
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4932
Reviewed-by: https://github.com/kalenikaliaksandr ✅
2 changed files with 7 additions and 0 deletions
|
@ -1344,6 +1344,12 @@ ScopedOperand Generator::add_constant(Value value)
|
|||
return append_new_constant();
|
||||
});
|
||||
}
|
||||
if (value.is_string()) {
|
||||
auto as_string = value.as_string().utf8_string();
|
||||
return m_string_constants.ensure(as_string, [&] {
|
||||
return append_new_constant();
|
||||
});
|
||||
}
|
||||
return append_new_constant();
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue