Skip to content

Use native maps when they're available - #12715

Merged
30 commits merged into
masterfrom
map5
Jan 17, 2017
Merged

30 commits merged into
masterfrom
map5

Conversation

@ghost

@ghost Deleted user (ghost) commented Dec 7, 2016 •

Copy link
Copy Markdown

Similar to #11354, but simpler.

  • Keeps using Map<T> instead of Map<K, V>, with K assumed to be string. For number-keyed maps we now use sparse arrays.
  • Does not include Set -- this can be done later.
  • Does not include sortInV8ObjectInsertionOrder; changes baselines instead. We won't be able to pass all tests when using the shim map, but we no longer run tests on node 0.10 anyway.

Added functions

Name Use
arrayFrom Converts anIterator to an Array. arrayFrom(map.keys()) replaces Object.keys(map). arrayFrom(map.values()) also lets us remove reduceProperties, which was only used to compute that.
forEachEntry, forEachKey These replace for-in loops with early termination, forEachProperty, and someProperties.
copyEntries Replaces copyProperties.
createMultiMap Replaces multiMapAdd and multiMapRemove.
mapsAreEqual Replaces a use of equalOwnProperties. Used only in reuseProgramStructure.ts, so moved it there.
multiMapSparseArrayAdd Replaces a use of multiMapAdd on what is now a sparse array. Used only in factory.ts, so moved it there.
mapEntries Replaces mapObject.

We also get rid of isEmpty and replace with map.size === 0.

Loading
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Breaking Change Would introduce errors in existing code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants