diff options
author | Mattias EngdegÄrd <mattiase@acm.org> | 2022-01-02 12:19:54 +0100 |
---|---|---|
committer | Mattias EngdegÄrd <mattiase@acm.org> | 2022-01-24 11:41:47 +0100 |
commit | 11e1abd5cc76c9adc72746c25688cf23365a9eb0 (patch) | |
tree | d33a2457222b61710505dbf40fe66333773da135 | |
parent | 721357b86856505324b5f32584d5eae0ba9ab4ac (diff) | |
download | emacs-11e1abd5cc76c9adc72746c25688cf23365a9eb0.tar.gz |
Open-code aref and aset in bytecode interpreter
* src/bytecode.c (exec_byte_code): Inline aref and aset for
vectors and records, since this is important for code that makes heavy
use of arrays and/or objects.
-rw-r--r-- | src/bytecode.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/src/bytecode.c b/src/bytecode.c index b2e8f4a9166..76ef2fb661c 100644 --- a/src/bytecode.c +++ b/src/bytecode.c @@ -948,15 +948,39 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth, CASE (Baref): { - Lisp_Object v1 = POP; - TOP = Faref (TOP, v1); + Lisp_Object idxval = POP; + Lisp_Object arrayval = TOP; + ptrdiff_t size; + ptrdiff_t idx; + if (((VECTORP (arrayval) && (size = ASIZE (arrayval), true)) + || (RECORDP (arrayval) && (size = PVSIZE (arrayval), true))) + && FIXNUMP (idxval) + && (idx = XFIXNUM (idxval), + idx >= 0 && idx < size)) + TOP = AREF (arrayval, idx); + else + TOP = Faref (arrayval, idxval); NEXT; } CASE (Baset): { - Lisp_Object v2 = POP, v1 = POP; - TOP = Faset (TOP, v1, v2); + Lisp_Object newelt = POP; + Lisp_Object idxval = POP; + Lisp_Object arrayval = TOP; + ptrdiff_t size; + ptrdiff_t idx; + if (((VECTORP (arrayval) && (size = ASIZE (arrayval), true)) + || (RECORDP (arrayval) && (size = PVSIZE (arrayval), true))) + && FIXNUMP (idxval) + && (idx = XFIXNUM (idxval), + idx >= 0 && idx < size)) + { + ASET (arrayval, idx, newelt); + TOP = newelt; + } + else + TOP = Faset (arrayval, idxval, newelt); NEXT; } |