Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:19
erlang
4091-Optimize-comparison-of-equal-terms.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 4091-Optimize-comparison-of-equal-terms.patch of Package erlang
From ba77daa4dd35041c7c381ae9f19ac7cdf25798cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Wed, 27 Jul 2022 09:26:32 +0200 Subject: [PATCH] Optimize comparison of equal terms When doing comparisons, be sure to avoid calling the quite expensive generic comparison routine for equal tagged values. In particular, the generic comparison function for atoms, `erts_cmp_atoms()`, will always call `memcmp()` for equal atoms longer than 4 characters, so we want to avoid that. --- erts/emulator/beam/beam_common.c | 2 +- erts/emulator/beam/erl_map.c | 2 +- erts/emulator/beam/jit/arm/instr_common.cpp | 8 ++++++++ erts/emulator/beam/jit/x86/instr_common.cpp | 8 ++++++++ 4 files changed, 18 insertions(+), 2 deletions(-) diff --git a/erts/emulator/beam/beam_emu.c b/erts/emulator/beam/beam_emu.c index 2055f60e91..6194644869 100644 --- a/erts/emulator/beam/beam_emu.c +++ b/erts/emulator/beam/beam_emu.c @@ -2846,7 +2846,7 @@ erts_gc_update_map_assoc(Process* p, Eterm* reg, Uint live, ASSERT(kp < (Eterm *)mp); key = *old_keys; - if ((c = CMP_TERM(key, new_key)) < 0) { + if ((c = (key == new_key) ? 0 : CMP_TERM(key, new_key)) < 0) { /* Copy old key and value */ *kp++ = key; *hp++ = *old_vals; diff --git a/erts/emulator/beam/erl_map.c b/erts/emulator/beam/erl_map.c index e0b881db0a..cb78bfe0f2 100644 --- a/erts/emulator/beam/erl_map.c +++ b/erts/emulator/beam/erl_map.c @@ -1378,7 +1378,7 @@ static Eterm flatmap_merge(Process *p, Eterm nodeA, Eterm nodeB) { vs2 = flatmap_get_values(mp2); while(i1 < n1 && i2 < n2) { - c = CMP_TERM(ks1[i1],ks2[i2]); + c = (ks1[i1] == ks2[i2]) ? 0 : CMP_TERM(ks1[i1],ks2[i2]); if (c == 0) { /* use righthand side arguments map value, * but advance both maps */ -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor