You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As is usually the case, the =cl-loop= macro expands to the most efficient code, which uses =(setq val (car ...=, =push=, and =nreverse=:
311
+
312
+
#+CAPTION: Expansion of =cl-loop= form in the benchmark.
313
+
#+BEGIN_SRC elisp
314
+
(cl-block nil
315
+
(let* ((--cl-var-- l)
316
+
(val nil)
317
+
(--cl-var-- nil))
318
+
(while (consp --cl-var--)
319
+
(setq val (car --cl-var--))
320
+
(push val --cl-var--)
321
+
(setq --cl-var-- (cdr --cl-var--)))
322
+
(nreverse --cl-var--)))
323
+
#+END_SRC
324
+
325
+
However, in some cases =cl-loop= may expand to code which uses =nconc=, which, as the benchmark shows, is much slower. In that case, you may write the loop without =cl-loop= to avoid using =nconc=.
326
+
269
327
**** Filtering a list
270
328
271
329
Using ~-select~ from =dash.el= seems to be the fastest way:
0 commit comments