mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:17:44 +00:00
LibJS: Shrink Identifier's environment coordinate cache
This patch does two things: - We now use u32 instead of size_t for the hops and index fields in EnvironmentCoordinate. This means we're limited to an environment nesting level and variable count of 4Gs respectively. - Instead of wrapping it in an Optional, EnvironmentCoordinate now has a custom valid/invalid state using a magic marker value. These two changes reduce the size of Identifier by 16 bytes. :^)
This commit is contained in:
parent
76f438eb3e
commit
0f1f925532
4 changed files with 16 additions and 10 deletions
|
@ -565,8 +565,11 @@ ThrowCompletionOr<Reference> VM::get_identifier_reference(Environment* environme
|
|||
|
||||
// Note: This is an optimization for looking up the same reference.
|
||||
Optional<EnvironmentCoordinate> environment_coordinate;
|
||||
if (index.has_value())
|
||||
environment_coordinate = EnvironmentCoordinate { .hops = hops, .index = index.value() };
|
||||
if (index.has_value()) {
|
||||
VERIFY(hops <= NumericLimits<u32>::max());
|
||||
VERIFY(index.value() <= NumericLimits<u32>::max());
|
||||
environment_coordinate = EnvironmentCoordinate { .hops = static_cast<u32>(hops), .index = static_cast<u32>(index.value()) };
|
||||
}
|
||||
|
||||
// 3. If exists is true, then
|
||||
if (exists) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue