aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2014-12-16 15:34:40 +0100
committerSverker Eriksson <[email protected]>2014-12-16 15:34:40 +0100
commit1717e36291bad837899fd5a35898ccef21358364 (patch)
tree340e0a4a7ecc8a81cdcb6f8fbb4bddb1f7e567e5 /erts/emulator/beam/erl_db.c
parentc4228fb7cb3bd651dd44f8dfd9a4f91f41d5cc2c (diff)
parentafd79e01d3375d8e8217b258ffb4d9b90541c922 (diff)
downloadotp-1717e36291bad837899fd5a35898ccef21358364.tar.gz
otp-1717e36291bad837899fd5a35898ccef21358364.tar.bz2
otp-1717e36291bad837899fd5a35898ccef21358364.zip
Merge branch 'sverk/ets-take-2/OTP-12309'
* sverk/ets-take-2/OTP-12309: erts: Optimize ets:lookup and ets:take for bags Implement ets:take/2
Diffstat (limited to 'erts/emulator/beam/erl_db.c')
-rw-r--r--erts/emulator/beam/erl_db.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_db.c b/erts/emulator/beam/erl_db.c
index 8f246ffa07..fba1e32230 100644
--- a/erts/emulator/beam/erl_db.c
+++ b/erts/emulator/beam/erl_db.c
@@ -753,6 +753,31 @@ BIF_RETTYPE ets_prev_2(BIF_ALIST_2)
BIF_RET(ret);
}
+/*
+** take(Tab, Key)
+*/
+BIF_RETTYPE ets_take_2(BIF_ALIST_2)
+{
+ DbTable* tb;
+#ifdef DEBUG
+ int cret;
+#endif
+ Eterm ret;
+ CHECK_TABLES();
+
+ tb = db_get_table(BIF_P, BIF_ARG_1, DB_WRITE, LCK_WRITE_REC);
+ if (!tb) {
+ BIF_ERROR(BIF_P, BADARG);
+ }
+#ifdef DEBUG
+ cret =
+#endif
+ tb->common.meth->db_take(BIF_P, tb, BIF_ARG_2, &ret);
+ ASSERT(cret == DB_ERROR_NONE);
+ db_unlock(tb, LCK_WRITE_REC);
+ BIF_RET(ret);
+}
+
/*
** update_element(Tab, Key, {Pos, Value})
** update_element(Tab, Key, [{Pos, Value}])