1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-13 09:32:47 +00:00

* Fix some comp-vec logic

* lisp/emacs-lisp/comp.el (comp-vec-length, comp-vec-append)
	(comp-vec-prepend): Fix logic.
	(comp-vec-aref): Fix indentation.
This commit is contained in:
Andrea Corallo 2021-02-25 20:46:27 +01:00
parent 9ae48ae714
commit 3a31fca5db

View File

@ -617,7 +617,7 @@ Useful to hook into pass checkers.")
(defsubst comp-vec-length (vec)
"Return the number of elements of VEC."
(+ (comp-vec-beg vec) (comp-vec-end vec)))
(- (comp-vec-end vec) (comp-vec-beg vec)))
(defsubst comp-vec--verify-idx (vec idx)
"Check idx is in bounds for VEC."
@ -628,21 +628,21 @@ Useful to hook into pass checkers.")
"Return the element of VEC at index IDX."
(declare (gv-setter (lambda (val)
`(comp-vec--verify-idx ,vec ,idx)
`(puthash ,idx ,val (comp-vec-data ,vec)))))
`(puthash ,idx ,val (comp-vec-data ,vec)))))
(comp-vec--verify-idx vec idx)
(gethash idx (comp-vec-data vec)))
(defsubst comp-vec-append (vec elt)
"Append ELT into VEC.
ELT is returned."
(puthash (comp-vec-end vec) elt (comp-vec-aref vec))
(puthash (comp-vec-end vec) elt (comp-vec-data vec))
(cl-incf (comp-vec-end vec))
elt)
(defsubst comp-vec-prepend (vec elt)
"Prepend ELT into VEC.
ELT is returned."
(puthash (comp-vec-beg vec) elt (comp-vec-aref vec))
(puthash (1- (comp-vec-beg vec)) elt (comp-vec-data vec))
(cl-decf (comp-vec-beg vec))
elt)