aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_db_util.c
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-05-06 19:29:34 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-05-07 10:17:21 +0200
commitdc177967363d16c155042dbaa2c911f59f0efd55 (patch)
tree05643e592657ff127893191596aeeaae4ebff860 /erts/emulator/beam/erl_db_util.c
parentf436d84d990bb06e6bbbf55659d4f3a47bc1c556 (diff)
downloadotp-dc177967363d16c155042dbaa2c911f59f0efd55.tar.gz
otp-dc177967363d16c155042dbaa2c911f59f0efd55.tar.bz2
otp-dc177967363d16c155042dbaa2c911f59f0efd55.zip
erts: ETS ordered_set cannot use it's optimization with Maps
The optimization cannot be used due to that the pattern cannot be ordered.
Diffstat (limited to 'erts/emulator/beam/erl_db_util.c')
-rw-r--r--erts/emulator/beam/erl_db_util.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_db_util.c b/erts/emulator/beam/erl_db_util.c
index 0fb1c397c9..be988f0621 100644
--- a/erts/emulator/beam/erl_db_util.c
+++ b/erts/emulator/beam/erl_db_util.c
@@ -3347,6 +3347,37 @@ int db_is_variable(Eterm obj)
return N;
}
+/* check if node is (or contains) a map
+ * return 1 if node contains a map
+ * return 0 otherwise
+ */
+
+int db_has_map(Eterm node) {
+ DECLARE_ESTACK(s);
+
+ ESTACK_PUSH(s,node);
+ while (!ESTACK_ISEMPTY(s)) {
+ node = ESTACK_POP(s);
+ if (is_list(node)) {
+ while (is_list(node)) {
+ ESTACK_PUSH(s,CAR(list_val(node)));
+ node = CDR(list_val(node));
+ }
+ ESTACK_PUSH(s,node); /* Non wellformed list or [] */
+ } else if (is_tuple(node)) {
+ Eterm *tuple = tuple_val(node);
+ int arity = arityval(*tuple);
+ while(arity--) {
+ ESTACK_PUSH(s,*(++tuple));
+ }
+ } else if is_map(node) {
+ DESTROY_ESTACK(s);
+ return 1;
+ }
+ }
+ DESTROY_ESTACK(s);
+ return 0;
+}
/* check if obj is (or contains) a variable */
/* return 1 if obj contains a variable or underscore */