[Emacs] Go back to while loop in csetq

While more elegant, `cl-loop` has a heavier setup which can make it
much slower than a while loop in the long run.
This commit is contained in:
Lucien Cartier-Tilet 2022-08-14 13:13:17 +02:00
parent 31817f8452
commit 582178a906
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA

View File

@ -487,8 +487,13 @@ The return value of `csetq' is the value of the last VAL.
(when (= (mod (length forms) 2) 1) (when (= (mod (length forms) 2) 1)
(signal 'wrong-number-of-arguments (list 'csetq (1+ (length forms))))) (signal 'wrong-number-of-arguments (list 'csetq (1+ (length forms)))))
;; Transform FORMS into a list of pairs (FORM . VALUE) ;; Transform FORMS into a list of pairs (FORM . VALUE)
`(progn ,@(cl-loop for (form value) on forms by 'cddr (let (sexps)
collect `(customize-set-variable ',form ,value)))) (while forms
(let ((form (pop forms))
(value (pop forms)))
(push `(customize-set-variable ',form ,value)
sexps)))
`(progn ,@(nreverse sexps))))
#+end_src #+end_src
I first got inspired by [[https://oremacs.com/2015/01/17/setting-up-ediff/][this blog article]] (archived article, just in I first got inspired by [[https://oremacs.com/2015/01/17/setting-up-ediff/][this blog article]] (archived article, just in