aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/utils.c
diff options
context:
space:
mode:
authorPhilip Stears <[email protected]>2018-02-06 13:59:00 +0100
committerPhilip Stears <[email protected]>2018-02-08 15:37:06 +0100
commitad29b4d489b5a3f1139d3307a67c544b93995e26 (patch)
treef612b3bd5f35738c1802961f50f6e9d5b0ae4621 /erts/emulator/beam/utils.c
parent3cb3d5c1927e6235b0e51ba7ca31e2a3458fba01 (diff)
downloadotp-ad29b4d489b5a3f1139d3307a67c544b93995e26.tar.gz
otp-ad29b4d489b5a3f1139d3307a67c544b93995e26.tar.bz2
otp-ad29b4d489b5a3f1139d3307a67c544b93995e26.zip
Optimize non-strict equality check of binaries differing in size
This commit brings the perform of a non-strict equality check of binaries into the same range as strict ones. Currently, these checks can be significantly slower because they go through the general comparison code which doesn't have an optimization to check the size before comparing contents in the case that it's checking equality.
Diffstat (limited to 'erts/emulator/beam/utils.c')
-rw-r--r--erts/emulator/beam/utils.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/erts/emulator/beam/utils.c b/erts/emulator/beam/utils.c
index fe9f1c7606..4bf60619ba 100644
--- a/erts/emulator/beam/utils.c
+++ b/erts/emulator/beam/utils.c
@@ -3152,6 +3152,9 @@ tailrecur_ne:
int cmp;
byte* a_ptr;
byte* b_ptr;
+ if (eq_only && a_size != b_size) {
+ RETURN_NEQ(a_size - b_size);
+ }
ERTS_GET_BINARY_BYTES(a, a_ptr, a_bitoffs, a_bitsize);
ERTS_GET_BINARY_BYTES(b, b_ptr, b_bitoffs, b_bitsize);
if ((a_bitsize | b_bitsize | a_bitoffs | b_bitoffs) == 0) {