[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Performance issue w/ `cl-loop`s `collect...into`

From: Tianxiang Xiong
Subject: Re: Performance issue w/ `cl-loop`s `collect...into`
Date: Sun, 8 Apr 2018 01:50:16 -0700

Indeed, I modified the macroexpanded form into:

(cl-block nil
  (let* ((--cl-var-- (number-sequence 0 130000))
    (while (consp --cl-var--)
      (setq i (car --cl-var--))
      (let ((v (list (cons (number-to-string i) i))))
        (if (null pairs-end)
            (setq pairs v pairs-end (last pairs))
          (setq pairs-end (setcdr pairs-end v))))
      (setq --cl-var-- (cdr --cl-var--)))
    (length pairs)))

and it runs near instantaneously.

I'd guess the fix would be applied in `cl--parse-loop-clause`? Perhaps Stefan could give some pointers?

On Sat, Apr 7, 2018 at 11:12 PM, Clément Pit-Claudel <address@hidden> wrote:
On 2018-04-08 01:56, Tianxiang Xiong wrote:
> Yikes--wasn't expecting that. Similar code in SBCL runs nearly instantaneously.

Indeed, fixing the implementation would be nice.  It shouldn't be too hard to keep a reference to the last `cons' of `pairs' and to append to that using setcdr.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]