aboutsummaryrefslogtreecommitdiffstats
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorVibhav Pant2017-02-10 23:25:42 +0530
committerVibhav Pant2017-02-10 23:25:42 +0530
commitdcd0e6fe3ae24a716e1f665b12d877681bb8cc21 (patch)
treecdae0b151ed694e773cded013157e4ef93d2c528 /src/bytecode.c
parent2d10d4ad1a24727b9c1db6664bc8f92eaa3fd4c8 (diff)
downloademacs-dcd0e6fe3ae24a716e1f665b12d877681bb8cc21.tar.gz
emacs-dcd0e6fe3ae24a716e1f665b12d877681bb8cc21.zip
src/bytecode.c: Avoid comparing values unnecessarily in Bswitch
* src/bytecode.c: (exec_byte_code) While linear searching the jump table, compare the value's hash table first to avoid calling h->test.cmpfn every time.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index ed1eb178468..1ac28110320 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -1429,6 +1429,7 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1429 if (h->count <= 5) 1429 if (h->count <= 5)
1430 { /* Do a linear search if there are not many cases 1430 { /* Do a linear search if there are not many cases
1431 FIXME: 5 is arbitrarily chosen. */ 1431 FIXME: 5 is arbitrarily chosen. */
1432 EMACS_UINT hash_code = h->test.hashfn (&h->test, v1);
1432 for (i = 0; i < h->count; i++) 1433 for (i = 0; i < h->count; i++)
1433 { 1434 {
1434#ifdef BYTE_CODE_SAFE 1435#ifdef BYTE_CODE_SAFE
@@ -1439,8 +1440,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
1439 HASH_TABLE_SIZE (h) == h->count. */ 1440 HASH_TABLE_SIZE (h) == h->count. */
1440 1441
1441 if ((EQ (v1, HASH_KEY (h, i)) || 1442 if ((EQ (v1, HASH_KEY (h, i)) ||
1442 (h->test.cmpfn && 1443 (h->test.cmpfn
1443 h->test.cmpfn (&h->test, v1, HASH_KEY (h, i))))) 1444 && hash_code == XUINT (HASH_HASH (h, i))
1445 && h->test.cmpfn (&h->test, v1, HASH_KEY (h, i)))))
1444 { 1446 {
1445 op = XINT (HASH_VALUE (h, i)); 1447 op = XINT (HASH_VALUE (h, i));
1446 goto op_branch; 1448 goto op_branch;