[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] feature/byte-switch dcd0e6f: src/bytecode.c: Avoid compari
From: |
Vibhav Pant |
Subject: |
[Emacs-diffs] feature/byte-switch dcd0e6f: src/bytecode.c: Avoid comparing values unnecessarily in Bswitch |
Date: |
Fri, 10 Feb 2017 12:58:00 -0500 (EST) |
branch: feature/byte-switch
commit dcd0e6fe3ae24a716e1f665b12d877681bb8cc21
Author: Vibhav Pant <address@hidden>
Commit: Vibhav Pant <address@hidden>
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.
---
src/bytecode.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/src/bytecode.c b/src/bytecode.c
index ed1eb17..1ac2811 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,
if (h->count <= 5)
{ /* Do a linear search if there are not many cases
FIXME: 5 is arbitrarily chosen. */
+ EMACS_UINT hash_code = h->test.hashfn (&h->test, v1);
for (i = 0; i < h->count; i++)
{
#ifdef BYTE_CODE_SAFE
@@ -1439,8 +1440,9 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector,
Lisp_Object maxdepth,
HASH_TABLE_SIZE (h) == h->count. */
if ((EQ (v1, HASH_KEY (h, i)) ||
- (h->test.cmpfn &&
- h->test.cmpfn (&h->test, v1, HASH_KEY (h, i)))))
+ (h->test.cmpfn
+ && hash_code == XUINT (HASH_HASH (h, i))
+ && h->test.cmpfn (&h->test, v1, HASH_KEY (h, i)))))
{
op = XINT (HASH_VALUE (h, i));
goto op_branch;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Emacs-diffs] feature/byte-switch dcd0e6f: src/bytecode.c: Avoid comparing values unnecessarily in Bswitch,
Vibhav Pant <=