Improve byte-switch execution.

* lisp/emacs-lisp/byte-opt.el,
  lisp/emacs-lisp/bytecomp.el (byte-decompile-bytecode-1),
  (byte-compile-lapcode): Calculate the actual jump address while
  compiling, store it in the jump table.

* src/bytecode.c: Jump to the looked up value directly, do a linear
  search when the number of elements is <= 5.
This commit is contained in:
Vibhav Pant 2017-02-09 12:18:54 +05:30
parent 96c4e367f9
commit dde800c8c9
3 changed files with 33 additions and 15 deletions

View file

@ -1411,10 +1411,8 @@
;; Replace all addresses with TAGs.
(maphash #'(lambda (value tag)
(let (newtag)
(cl-assert (consp tag)
nil "Invalid address for byte-switch")
(setq newtag (byte-compile-make-tag))
(push (cons (+ (car tag) (lsh (cdr tag) 8)) newtag) tags)
(push (cons tag newtag) tags)
(puthash value newtag last-constant)))
last-constant)
;; Replace the hash table referenced in the lapcode with our