diff options
| author | Mattias EngdegÄrd | 2024-02-19 14:42:55 +0100 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-02-19 15:57:49 +0100 |
| commit | 23793600778c4efe5615b646f2d3895624c23ef0 (patch) | |
| tree | d5f86cde5fe6a632a041081f59a0f9b7e13e6711 /src/bytecode.c | |
| parent | 188fe6bffa69e08b60a7d65709998bd803b7ada5 (diff) | |
| download | emacs-23793600778c4efe5615b646f2d3895624c23ef0.tar.gz emacs-23793600778c4efe5615b646f2d3895624c23ef0.zip | |
Slight switch byte op speedup
* src/bytecode.c (exec_byte_code): Hoist symbols_with_pos_enabled check
from fast loop, and eliminate the initial index check.
Diffstat (limited to 'src/bytecode.c')
| -rw-r--r-- | src/bytecode.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index dd805cbd97a..8d7240b9966 100644 --- a/src/bytecode.c +++ b/src/bytecode.c | |||
| @@ -1737,28 +1737,29 @@ exec_byte_code (Lisp_Object fun, ptrdiff_t args_template, | |||
| 1737 | if (BYTE_CODE_SAFE && !HASH_TABLE_P (jmp_table)) | 1737 | if (BYTE_CODE_SAFE && !HASH_TABLE_P (jmp_table)) |
| 1738 | emacs_abort (); | 1738 | emacs_abort (); |
| 1739 | Lisp_Object v1 = POP; | 1739 | Lisp_Object v1 = POP; |
| 1740 | ptrdiff_t i; | ||
| 1741 | struct Lisp_Hash_Table *h = XHASH_TABLE (jmp_table); | 1740 | struct Lisp_Hash_Table *h = XHASH_TABLE (jmp_table); |
| 1742 | 1741 | /* Do a linear search if there are few cases and the test is `eq'. | |
| 1743 | /* h->count is a faster approximation for HASH_TABLE_SIZE (h) | 1742 | (The table is assumed to be sized exactly; all entries are |
| 1744 | here. */ | 1743 | consecutive at the beginning.) |
| 1745 | if (h->count <= 5 && !h->test->cmpfn) | 1744 | FIXME: 5 is arbitrarily chosen. */ |
| 1746 | { /* Do a linear search if there are not many cases | 1745 | if (h->count <= 5 && !h->test->cmpfn && !symbols_with_pos_enabled) |
| 1747 | FIXME: 5 is arbitrarily chosen. */ | 1746 | { |
| 1748 | for (i = h->count; 0 <= --i; ) | 1747 | eassume (h->count >= 2); |
| 1749 | if (EQ (v1, HASH_KEY (h, i))) | 1748 | for (ptrdiff_t i = h->count - 1; i >= 0; i--) |
| 1750 | break; | 1749 | if (BASE_EQ (v1, HASH_KEY (h, i))) |
| 1750 | { | ||
| 1751 | op = XFIXNUM (HASH_VALUE (h, i)); | ||
| 1752 | goto op_branch; | ||
| 1753 | } | ||
| 1751 | } | 1754 | } |
| 1752 | else | 1755 | else |
| 1753 | i = hash_lookup (h, v1); | ||
| 1754 | |||
| 1755 | if (i >= 0) | ||
| 1756 | { | 1756 | { |
| 1757 | Lisp_Object val = HASH_VALUE (h, i); | 1757 | ptrdiff_t i = hash_lookup (h, v1); |
| 1758 | if (BYTE_CODE_SAFE && !FIXNUMP (val)) | 1758 | if (i >= 0) |
| 1759 | emacs_abort (); | 1759 | { |
| 1760 | op = XFIXNUM (val); | 1760 | op = XFIXNUM (HASH_VALUE (h, i)); |
| 1761 | goto op_branch; | 1761 | goto op_branch; |
| 1762 | } | ||
| 1762 | } | 1763 | } |
| 1763 | } | 1764 | } |
| 1764 | NEXT; | 1765 | NEXT; |