aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--erts/emulator/beam/bif.tab1
-rw-r--r--erts/emulator/beam/erl_hashmap.c22
2 files changed, 23 insertions, 0 deletions
diff --git a/erts/emulator/beam/bif.tab b/erts/emulator/beam/bif.tab
index 6408883e96..c0fb1f8827 100644
--- a/erts/emulator/beam/bif.tab
+++ b/erts/emulator/beam/bif.tab
@@ -617,6 +617,7 @@ bif erlang:get_keys/0
# Hash Array Mappped Trie
bif hashmap:put/3
bif hashmap:get/2
+bif hashmap:find/2
bif hashmap:remove/2
bif hashmap:info/1
bif hashmap:to_list/1
diff --git a/erts/emulator/beam/erl_hashmap.c b/erts/emulator/beam/erl_hashmap.c
index 8e651dd776..a5d6daadd7 100644
--- a/erts/emulator/beam/erl_hashmap.c
+++ b/erts/emulator/beam/erl_hashmap.c
@@ -133,6 +133,28 @@ BIF_RETTYPE hashmap_get_2(BIF_ALIST_2) {
BIF_ERROR(BIF_P, BADARG);
}
+/* hashmap:find/2 */
+
+BIF_RETTYPE hashmap_find_2(BIF_ALIST_2) {
+ if (is_hashmap(BIF_ARG_2)) {
+ Eterm *hp, res;
+ const Eterm *value;
+ Uint32 hx = make_hash2(BIF_ARG_1);
+
+ if ((value = hashmap_get(hx, BIF_ARG_1, BIF_ARG_2)) != NULL) {
+ hp = HAlloc(BIF_P, 3);
+ res = make_tuple(hp);
+ *hp++ = make_arityval(2);
+ *hp++ = am_ok;
+ *hp++ = *value;
+ BIF_RET(res);
+ }
+ BIF_RET(am_error);
+ }
+ BIF_ERROR(BIF_P, BADARG);
+}
+
+
/* hashmap:remove/2 */
BIF_RETTYPE hashmap_remove_2(BIF_ALIST_2) {