aboutsummaryrefslogtreecommitdiffstats
path: root/erts
diff options
context:
space:
mode:
authorBjörn-Egil Dahlberg <[email protected]>2015-04-15 15:43:51 +0200
committerBjörn-Egil Dahlberg <[email protected]>2015-04-15 15:43:51 +0200
commit88b79b875731199a789bbda43d104ea9c8a1f235 (patch)
tree33b3c1a85a74d99d7f04ada40b98982ae968d58d /erts
parent0fc485a1b487f0b22daf2178e28b2f3edfdc7919 (diff)
downloadotp-88b79b875731199a789bbda43d104ea9c8a1f235.tar.gz
otp-88b79b875731199a789bbda43d104ea9c8a1f235.tar.bz2
otp-88b79b875731199a789bbda43d104ea9c8a1f235.zip
erts: Optimize comparison operator for frequent immediates
* small integers * atoms
Diffstat (limited to 'erts')
-rw-r--r--erts/emulator/beam/utils.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index aecfe04a75..4db2015eea 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -2922,15 +2922,44 @@ Sint cmp(Eterm a, Eterm b)
}
#endif
+#if HALFWORD_HEAP
+static Sint erts_cmp_compound_rel_opt(Eterm a, Eterm* a_base,
+ Eterm b, Eterm* b_base,
+ int exact, int eq_only);
+#else
+static Sint erts_cmp_compound(Eterm a, Eterm b, int exact, int eq_only);
+#endif
+
+#if HALFWORD_HEAP
+Sint erts_cmp(Eterm a, Eterm* a_base,
+ Eterm b, Eterm* b_base,
+ int exact, int eq_only)
+#else
+Sint erts_cmp(Eterm a, Eterm b, int exact, int eq_only)
+#endif
+{
+ if (is_atom(a) && is_atom(b)) {
+ return cmp_atoms(a, b);
+ } else if (is_both_small(a, b)) {
+ return (signed_val(a) - signed_val(b));
+ }
+#if HALFWORD_HEAP
+ return erts_cmp_compound(a,a_base,b,b_base,exact,eq_only);
+#else
+ return erts_cmp_compound(a,b,exact,eq_only);
+#endif
+}
+
+
/* erts_cmp(Eterm a, Eterm b, int exact)
* exact = 1 -> term-based compare
* exact = 0 -> arith-based compare
*/
#if HALFWORD_HEAP
-Sint erts_cmp_rel_opt(Eterm a, Eterm* a_base, Eterm b, Eterm* b_base,
+static Sint erts_cmp_compound_rel_opt(Eterm a, Eterm* a_base, Eterm b, Eterm* b_base,
int exact, int eq_only)
#else
-Sint erts_cmp(Eterm a, Eterm b, int exact, int eq_only)
+static Sint erts_cmp_compound(Eterm a, Eterm b, int exact, int eq_only)
#endif
{
#define PSTACK_TYPE struct erts_cmp_hashmap_state