Age | Commit message (Collapse) | Author |
|
Refactor maps.erl
|
|
This only touches functions that are not further manually enhanced in
erl_bif_types. The hope is that this will allow dialyzer to discover
more issues in code using maps.
|
|
Using direct pattern matching on the map is more effient than pattern
matching on the result of maps:find/2, because it avoids allocating the
intermediate tuple.
|
|
Implementing it in Erlang allows taking advantage of the literal pool
optimisation, this means the function implemented in Erlang does no
allocations, while the BIF had to allocate new map each time it was
called. Benchmarks show the function is also slightly faster now.
|
|
|
|
|
|
This iterator implementation fetches multiple elements to
iterate over in one call to erts_internal:maps_next instead
of one at a time. This means that the memory usage will go
up for the iterator as we are buffering elements, but the
usage is still bounded.
In this implementation the max memory usage is 1000 words.
Using this approach makes the iterator as fast as using
maps:to_list, so maps:iterator/2 has been removed.
|
|
|
|
This version does not work great as the subtrees
created are not proper hash maps. Also it is not
all that performant as the extra allocations to
keep the stack there is expensive.
|
|
|
|
Type information is stored in erl_bif_types for certain BIFs.
This fact must be stated in the type specification for the
stubs that are superceded by erl_bif_types.
* Shadowed by erl_bif_types: maps:from_list/1
* Shadowed by erl_bif_types: maps:get/2
* Shadowed by erl_bif_types: maps:is_key/2
* Shadowed by erl_bif_types: maps:merge/2
* Shadowed by erl_bif_types: maps:put/3
* Shadowed by erl_bif_types: maps:to_list/1
* Shadowed by erl_bif_types: maps:update/3
|
|
Maps equivalent to dict:update/3,4
|
|
|
|
|
|
The current implementation is roughly O(N*M) where N is the number of items to be removed, and M is the number of items in the map. This does not include the cost of `maps:from_list` or `maps:to_list`. This leads to pretty horrifying execution times on large maps regardless of how many or few keys are to be removed.
The new implementation is O(N) where N is the number of items to be removed. For each N there's the cost of removing a key from a map, and but in practice that turns out to be a vast improvement for all map sizes I tested
The new maps:take/2 implementation similarly builds a list of keys and values by iterating only the list of desired keys, and then hands it off to maps:from_list. This turned out to be faster than N maps:put calls.
|
|
|
|
|
|
|
|
Bad input to maps module function will now yield exceptions:
* {badmap,NotMap} or,
* badarg
|
|
* kittee/maps_only:
maps:only/2 -> maps:with/2
add maps:only/2
|
|
|
|
|
|
probably a copy&paste error from maps:keys()
|
|
|
|
|
|
|
|
The HiPE compiler crashes when trying to compile these files because
it does not currently support maps. So, add a -compile(no_native)
attribute to these files to allow the system to be made even when
configured with --enable-native-libs.
This is a temporary fix and will be removed when the HiPE compiler
gets proper support for maps.
|
|
This means replacing maps:foldl/3 and maps:foldr/3 with maps:fold/3.
|
|
This commit requires Map enabled bootstrap compiler.
|
|
|
|
Name conforms to EEP.
|