forked from facebook/hhvm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make Map use a MixedArray for its buffer
Summary: This diff changes Map to use a MixedArray for its buffer instead of using its own custom buffers. The intent is to clear the way for enabling fast (usually O(1)) conversion between Maps and map-like arrays. Making this work was a little trickier than it was to make Vectors use arrays as buffers. Here is a summary of the significant changes: - Maps no longer define their own Elm struct, but instead use MixedArray's Elm struct. - The Map implementation has been refined to shrink its capacity under certain conditions. I noticed this was a problem when I looked at the Map::addAll(), and since I was ripping up and re-writing that part of the Map implementation anyway I decided to address this issue in this diff. - While Map logic still controls when growing, compacting, and shrinking are triggered, Maps now delegate to various MixedArray methods to actually perform grow, compaction, and shrink operations. Maps also delegate to MixedArray for findForRemove and eraseNoCompact. - A number of Map fields (m_used, m_cap, etc) were removed and instead we now just use the equivalent fields in the Map's MixedArray buffer. - Maps now keep track of whether there might be int-like string keys present. This was essential to make Map::toArray() efficient in most cases but still get behavior correct in the rare case where a Map contains int-like string keys. - While writing this diff I tripped over an issue where wordcpy() was going off the rails if you pass it a zero size, so I added asserts in various parts of the code to help avoid this pitfall. - There are more opportunities for code sharing between MixedArrays and Maps, but I've deferred a fair amount of that to keep this diff smaller and easier to review. Reviewed By: @dariorussi Differential Revision: D1383777
- Loading branch information
1 parent
298c1bb
commit 8358688
Showing
11 changed files
with
757 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.