Skip to content
Snippets Groups Projects
Commit cc46824b authored by Attila Lendvai's avatar Attila Lendvai
Browse files

Replace DELETE-FROM-PLIST implementation, shorter and faster.

Suggested by Stas Boukarev.
parent 048de2e5
No related branches found
No related tags found
No related merge requests found
......@@ -279,19 +279,8 @@ not destructively modified. Keys are compared using EQ."
"Just like REMOVE-FROM-PLIST, but this version may destructively modify the
provided plist."
(declare (optimize speed))
(loop with head = plist
with tail = nil ; a nil tail means an empty result so far
for (key . rest) on plist by #'cddr
do (assert rest () "Expected a proper plist, got ~S" plist)
(if (member key keys :test #'eq)
;; skip over this pair
(symbol-macrolet ((next (cdr rest)))
(if tail
(setf (cdr tail) next)
(setf head next)))
;; keep this pair
(setf tail rest))
finally (return head)))
(dolist (key keys plist)
(remf plist key)))
(define-modify-macro remove-from-plistf (&rest keys) remove-from-plist
"Modify macro for REMOVE-FROM-PLIST.")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment