diff options
author | Björn-Egil Dahlberg <[email protected]> | 2016-04-01 16:16:46 +0200 |
---|---|---|
committer | Björn-Egil Dahlberg <[email protected]> | 2016-04-01 16:16:46 +0200 |
commit | f86eabba45b351890ea8a12bd976c02b799c0e93 (patch) | |
tree | dbcac6317bed741fc833777c0d932ef977c05f78 | |
parent | 785079d7d9c797b57dce9f8ff4dbf4b4fb7042a9 (diff) | |
download | otp-f86eabba45b351890ea8a12bd976c02b799c0e93.tar.gz otp-f86eabba45b351890ea8a12bd976c02b799c0e93.tar.bz2 otp-f86eabba45b351890ea8a12bd976c02b799c0e93.zip |
erts: Don't search for non-existing Map keys twice
* For maps:get/2,3 and maps:find/2, searching for an immediate key, e.g. an atom,
the search was performed twice if the key did not exist in the map.
-rw-r--r-- | erts/emulator/beam/erl_map.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c index 4b6931f848..6b747256e1 100644 --- a/erts/emulator/beam/erl_map.c +++ b/erts/emulator/beam/erl_map.c @@ -196,13 +196,13 @@ erts_maps_get(Eterm key, Eterm map) return &vs[i]; } } - } - - for (i = 0; i < n; i++) { - if (EQ(ks[i], key)) { - return &vs[i]; - } - } + } else { + for (i = 0; i < n; i++) { + if (EQ(ks[i], key)) { + return &vs[i]; + } + } + } return NULL; } ASSERT(is_hashmap(map)); |