|
From: | Stefan Monnier |
Subject: | Re: How to get plist properties list? |
Date: | Fri, 08 Jan 2021 00:20:59 -0500 |
User-agent: | Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (dotimes (i length (reverse properties)) > (if (divisible-by-2-or-0-p i) > (push (elt plist i) properties))))) This is another example of a dotimes+elt loop, i.e. a loop where you end up with an unwarranted O(n²) complexity (i.e. a performance bug). > (while (/= n (length plist)) > (push (elt plist n) properties) > (setq n (+ 2 n))) > properties)) Same problem here. > But maybe there is some more simpler way to get plist properties list? Probably not the simplest but this should work: (defun plist-keys (plist) (let (keys iskey) (dolist (x plist) (if (setq iskey (not iskey)) (push x keys))) (nreverse keys))) The simplest might be: (map-keys plist) -- Stefan
[Prev in Thread] | Current Thread | [Next in Thread] |