aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db_tree.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2018-11-01 16:55:44 +0100
committerSverker Eriksson <[email protected]>2018-11-01 17:48:20 +0100
commit286107442268176bd928f99d53d4c7f1a0ea688f (patch)
tree5f3f7165d891a7ea3aef7edbc8382f32209329c5 /erts/emulator/beam/erl_db_tree.c
parente5b006ce3361467f77c372a4b6f19f9e0d9ddf23 (diff)
downloadotp-286107442268176bd928f99d53d4c7f1a0ea688f.tar.gz
otp-286107442268176bd928f99d53d4c7f1a0ea688f.tar.bz2
otp-286107442268176bd928f99d53d4c7f1a0ea688f.zip
erts: Tidy some ordered_set iteration code
with variable name changes, some comments and moved catree_find_prev_from_pb_key_root after its twin.
Diffstat (limited to 'erts/emulator/beam/erl_db_tree.c')
-rw-r--r--erts/emulator/beam/erl_db_tree.c32
1 files changed, 26 insertions, 6 deletions
diff --git a/erts/emulator/beam/erl_db_tree.c b/erts/emulator/beam/erl_db_tree.c
index f5fac9dcb6..02a5934a6e 100644
--- a/erts/emulator/beam/erl_db_tree.c
+++ b/erts/emulator/beam/erl_db_tree.c
@@ -2963,8 +2963,18 @@ found_prev:
}
+/* @brief Find object with smallest key of all larger than partially bound key.
+ * Can be used as a starting point for a reverse iteration with pb_key.
+ *
+ * @param pb_key The partially bound key. Example {42, '$1'}
+ * @param *rootpp Will return pointer to root pointer of tree with found object.
+ * @param iter Root iterator or NULL for plain DbTableTree.
+ * @param stack A stack to use. Will be cleared.
+ *
+ * @return found object or NULL if no such key exists.
+ */
static TreeDbTerm *find_next_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
- DbTreeStack* stack, Eterm key,
+ DbTreeStack* stack, Eterm pb_key,
CATreeRootIterator* iter)
{
TreeDbTerm* root;
@@ -2973,7 +2983,7 @@ static TreeDbTerm *find_next_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
Sint c;
if (iter) {
- *rootpp = catree_find_next_from_pb_key_root(key, iter);
+ *rootpp = catree_find_next_from_pb_key_root(pb_key, iter);
ASSERT(*rootpp);
root = **rootpp;
}
@@ -2988,7 +2998,7 @@ static TreeDbTerm *find_next_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
return NULL;
for (;;) {
PUSH_NODE(stack, this);
- if (( c = cmp_partly_bound(key,GETKEY(tbl, this->dbterm.tpl))) >= 0) {
+ if (( c = cmp_partly_bound(pb_key,GETKEY(tbl, this->dbterm.tpl))) >= 0) {
if (this->right == NULL) {
stack->pos = candidate;
return TOP_NODE(stack);
@@ -3003,8 +3013,18 @@ static TreeDbTerm *find_next_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
}
}
+/* @brief Find object with largest key of all smaller than partially bound key.
+ * Can be used as a starting point for a forward iteration with pb_key.
+ *
+ * @param pb_key The partially bound key. Example {42, '$1'}
+ * @param *rootpp Will return pointer to root pointer of found object.
+ * @param iter Root iterator or NULL for plain DbTableTree.
+ * @param stack A stack to use. Will be cleared.
+ *
+ * @return found object or NULL if no such key exists.
+ */
static TreeDbTerm *find_prev_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
- DbTreeStack* stack, Eterm key,
+ DbTreeStack* stack, Eterm pb_key,
CATreeRootIterator* iter)
{
TreeDbTerm* root;
@@ -3013,7 +3033,7 @@ static TreeDbTerm *find_prev_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
Sint c;
if (iter) {
- *rootpp = catree_find_prev_from_pb_key_root(key, iter);
+ *rootpp = catree_find_prev_from_pb_key_root(pb_key, iter);
ASSERT(*rootpp);
root = **rootpp;
}
@@ -3028,7 +3048,7 @@ static TreeDbTerm *find_prev_from_pb_key(DbTable *tbl, TreeDbTerm*** rootpp,
return NULL;
for (;;) {
PUSH_NODE(stack, this);
- if (( c = cmp_partly_bound(key,GETKEY(tbl, this->dbterm.tpl))) <= 0) {
+ if (( c = cmp_partly_bound(pb_key,GETKEY(tbl, this->dbterm.tpl))) <= 0) {
if (this->left == NULL) {
stack->pos = candidate;
return TOP_NODE(stack);