aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bif_persistent.c
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2019-02-15 09:56:20 +0100
committerBjörn Gustavsson <[email protected]>2019-02-15 09:56:20 +0100
commitb4466ab778ae2278e29625d4b8220af3797fa3b6 (patch)
tree5dbb32a022aa76d71971e42c25e4173d74e1c16d /erts/emulator/beam/erl_bif_persistent.c
parent11d4a893e50b1738b01846a5e669addb3e5a4f75 (diff)
parent595c159823089d0186ec2617c174356d1ff2de65 (diff)
downloadotp-b4466ab778ae2278e29625d4b8220af3797fa3b6.tar.gz
otp-b4466ab778ae2278e29625d4b8220af3797fa3b6.tar.bz2
otp-b4466ab778ae2278e29625d4b8220af3797fa3b6.zip
Merge branch 'maint'
* maint: Add persistent_term:get(Key, DefaultValue) Make dialyzer faster for left-associative andalso/orelse expressions
Diffstat (limited to 'erts/emulator/beam/erl_bif_persistent.c')
-rw-r--r--erts/emulator/beam/erl_bif_persistent.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_bif_persistent.c b/erts/emulator/beam/erl_bif_persistent.c
index 9dca768a18..5a78a043ce 100644
--- a/erts/emulator/beam/erl_bif_persistent.c
+++ b/erts/emulator/beam/erl_bif_persistent.c
@@ -332,6 +332,23 @@ BIF_RETTYPE persistent_term_get_1(BIF_ALIST_1)
BIF_ERROR(BIF_P, BADARG);
}
+BIF_RETTYPE persistent_term_get_2(BIF_ALIST_2)
+{
+ Eterm key = BIF_ARG_1;
+ Eterm result = BIF_ARG_2;
+ HashTable* hash_table = (HashTable *) erts_atomic_read_nob(&the_hash_table);
+ Uint entry_index;
+ Eterm term;
+
+ entry_index = lookup(hash_table, key);
+ term = hash_table->term[entry_index];
+ if (is_boxed(term)) {
+ ASSERT(is_tuple_arity(term, 2));
+ result = tuple_val(term)[2];
+ }
+ BIF_RET(result);
+}
+
BIF_RETTYPE persistent_term_erase_1(BIF_ALIST_1)
{
Eterm key = BIF_ARG_1;