Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'object' part of Tuple is not 'hoisted' to the start of the trie #10

Open
acutmore opened this issue Apr 3, 2024 · 0 comments
Open

Comments

@acutmore
Copy link

acutmore commented Apr 3, 2024

As per the README

Astute readers may object that some bookkeeping data remains in memory when you create tuple objects with prefixes of primitive values

This can be solved by 'hoisting' the object parts of the key to the front before performing the lookup. i.e.:

Tuple(1, 2, Object);

Tuple(1, Object, 2);

can interally lookup the tuples for:

[Object, 1, 2, Object]

[Object, 1, Object, 2]

This does make the lookup O(2n), but that is still O(n).

Note: this also doesn't only apply to objects, now that https://github.com/tc39/proposal-symbols-as-weakmap-keys is part of the spec, non-registered symbols can also be 'hoisted' to the start of the key too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant