benjamn / benjamn/immutable-tuple

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

Open
#10 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
38
Forks
3
PR merge metrics
No merged PRs in 30d

Description

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.:

```js
Tuple(1, 2, Object);

Tuple(1, Object, 2);
```

can interally lookup the tuples for:

```js
[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.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.