From ad29b4d489b5a3f1139d3307a67c544b93995e26 Mon Sep 17 00:00:00 2001 From: Philip Stears Date: Tue, 6 Feb 2018 13:59:00 +0100 Subject: 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. --- erts/emulator/beam/utils.c | 3 +++ 1 file changed, 3 insertions(+) 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) { -- cgit v1.2.3