aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_bits.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-11-26 20:31:43 +0100
committerSverker Eriksson <[email protected]>2013-11-26 20:33:25 +0100
commitf3589a79de29f1a4e6a2d03518739af214ae9600 (patch)
treedb1a570ad0c4b49a739099f742fa3b69d79e7042 /erts/emulator/beam/erl_bits.c
parenta1ce4da11ca0710a166e5048251aa1e128a83695 (diff)
downloadotp-f3589a79de29f1a4e6a2d03518739af214ae9600.tar.gz
otp-f3589a79de29f1a4e6a2d03518739af214ae9600.tar.bz2
otp-f3589a79de29f1a4e6a2d03518739af214ae9600.zip
erts: Optimize comparison for bitstrings with byte aligned start
Diffstat (limited to 'erts/emulator/beam/erl_bits.c')
-rw-r--r--erts/emulator/beam/erl_bits.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/erts/emulator/beam/erl_bits.c b/erts/emulator/beam/erl_bits.c
index d5b0e341a1..872ded4be7 100644
--- a/erts/emulator/beam/erl_bits.c
+++ b/erts/emulator/beam/erl_bits.c
@@ -1823,25 +1823,27 @@ erts_cmp_bits(byte* a_ptr, size_t a_offs, byte* b_ptr, size_t b_offs, size_t siz
/* Compare bit by bit until a_ptr is aligned on byte boundary */
a = *a_ptr++;
b = *b_ptr++;
- for (;;) {
- a_bit = get_bit(a, a_offs);
- b_bit = get_bit(b, b_offs);
- if ((cmp = (a_bit-b_bit)) != 0) {
- return cmp;
- }
- if (--size == 0)
- return 0;
+ if (a_offs) {
+ for (;;) {
+ a_bit = get_bit(a, a_offs);
+ b_bit = get_bit(b, b_offs);
+ if ((cmp = (a_bit-b_bit)) != 0) {
+ return cmp;
+ }
+ if (--size == 0)
+ return 0;
- b_offs++;
- if (b_offs == 8) {
- b_offs = 0;
- b = *b_ptr++;
- }
- a_offs++;
- if (a_offs == 8) {
- a_offs = 0;
- a = *a_ptr++;
- break;
+ b_offs++;
+ if (b_offs == 8) {
+ b_offs = 0;
+ b = *b_ptr++;
+ }
+ a_offs++;
+ if (a_offs == 8) {
+ a_offs = 0;
+ a = *a_ptr++;
+ break;
+ }
}
}
@@ -1879,10 +1881,8 @@ erts_cmp_bits(byte* a_ptr, size_t a_offs, byte* b_ptr, size_t b_offs, size_t siz
return 0;
a_offs++;
- if (a_offs == 8) {
- a_offs = 0;
- a = *a_ptr++;
- }
+ ASSERT(a_offs < 8);
+
b_offs++;
if (b_offs == 8) {
b_offs = 0;