diff options
author | Sverker Eriksson <[email protected]> | 2019-02-11 14:39:29 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2019-02-11 14:39:29 +0100 |
commit | 0a72d1714f7d7f447a78433451c39c75da6ae103 (patch) | |
tree | faa36fce39c50fdd358ee5c4d87b306ef5312d93 | |
parent | b34fc22d8b336b9b5a3d02d30ea22e16f3f1ddce (diff) | |
parent | 2e36105479b300a6c51e21b31e03ded39df8c02b (diff) | |
download | otp-0a72d1714f7d7f447a78433451c39c75da6ae103.tar.gz otp-0a72d1714f7d7f447a78433451c39c75da6ae103.tar.bz2 otp-0a72d1714f7d7f447a78433451c39c75da6ae103.zip |
Merge branch 'sverker/map-from-ks-vs-bug/OTP-15567' into maint
* sverker/map-from-ks-vs-bug/OTP-15567:
erts: Add test for bug in enif_make_maps_from_arrays
erts: Fix bug in erts_map_from_ks_and_vs
-rw-r--r-- | erts/emulator/beam/erl_map.c | 2 | ||||
-rw-r--r-- | erts/emulator/test/nif_SUITE.erl | 16 |
2 files changed, 17 insertions, 1 deletions
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c index cba17d3e6a..8f96dc3d23 100644 --- a/erts/emulator/beam/erl_map.c +++ b/erts/emulator/beam/erl_map.c @@ -475,7 +475,7 @@ Eterm erts_hashmap_from_array(ErtsHeapFactory* factory, Eterm *leafs, Uint n, Eterm erts_map_from_ks_and_vs(ErtsHeapFactory *factory, Eterm *ks0, Eterm *vs0, Uint n) { - if (n < MAP_SMALL_MAP_LIMIT) { + if (n <= MAP_SMALL_MAP_LIMIT) { Eterm *ks, *vs, *hp; flatmap_t *mp; Eterm keys; diff --git a/erts/emulator/test/nif_SUITE.erl b/erts/emulator/test/nif_SUITE.erl index a2f3489943..ca5f90621f 100644 --- a/erts/emulator/test/nif_SUITE.erl +++ b/erts/emulator/test/nif_SUITE.erl @@ -1175,6 +1175,15 @@ maps(Config) when is_list(Config) -> M2 = maps_from_list_nif(maps:to_list(M2)), M3 = maps_from_list_nif(maps:to_list(M3)), + %% Test different map sizes (OTP-15567) + repeat_while(fun({35,_}) -> false; + ({K,Map}) -> + Map = maps_from_list_nif(maps:to_list(Map)), + Map = maps:filter(fun(K,V) -> V =:= K*100 end, Map), + {K+1, maps:put(K,K*100,Map)} + end, + {1,#{}}), + has_duplicate_keys = maps_from_list_nif([{1,1},{1,1}]), verify_tmpmem(TmpMem), @@ -2471,6 +2480,13 @@ repeat(0, _, Arg) -> repeat(N, Fun, Arg0) -> repeat(N-1, Fun, Fun(Arg0)). +repeat_while(Fun, Acc0) -> + case Fun(Acc0) of + false -> ok; + Acc1 -> + repeat_while(Fun, Acc1) + end. + check(Exp,Got,Line) -> case Got of Exp -> Exp; |