aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db_tree.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2017-03-09 16:23:04 +0100
committerGuilherme Andrade <[email protected]>2017-03-22 23:57:55 +0000
commit5e18e917f29ed46caffa1211eb52ade01d24366a (patch)
treee38aba943e590b5b9f18173d79493d4b0c2a257b /erts/emulator/beam/erl_db_tree.c
parent865f06f93db7a68533bbdc4c961dd45699d6a07f (diff)
downloadotp-5e18e917f29ed46caffa1211eb52ade01d24366a.tar.gz
otp-5e18e917f29ed46caffa1211eb52ade01d24366a.tar.bz2
otp-5e18e917f29ed46caffa1211eb52ade01d24366a.zip
erts: Optimize ets:select_replace to not use heap
for temporary matchspec results. ToDo: Would be even nicer if PAM could allocate and build the ETS objects without extra copy_struct needed.
Diffstat (limited to 'erts/emulator/beam/erl_db_tree.c')
-rw-r--r--erts/emulator/beam/erl_db_tree.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c
index fadd63be34..60bf7fc979 100644
--- a/erts/emulator/beam/erl_db_tree.c
+++ b/erts/emulator/beam/erl_db_tree.c
@@ -3473,13 +3473,20 @@ static int doit_select_replace(DbTableTree *tb, TreeDbTerm **this, void *ptr,
&(*this)->dbterm, NULL, 0);
if (is_value(ret)) {
+ TreeDbTerm* new;
+ TreeDbTerm* old = *this;
#ifdef DEBUG
Eterm key = db_getkey(tb->common.keypos, ret);
ASSERT(is_value(key));
ASSERT(cmp_key(tb, key, old) == 0);
#endif
- *this = replace_dbterm(tb, *this, ret);
- sc->lastobj = (*this)->dbterm.tpl;
+ new = new_dbterm(tb, ret);
+ new->left = old->left;
+ new->right = old->right;
+ new->balance = old->balance;
+ sc->lastobj = new->dbterm.tpl;
+ *this = new;
+ free_term(tb, old);
++(sc->replaced);
}
if (--(sc->max) <= 0) {