From cc46824b16d36a2b4fc067cf34f3f6bb066c8c84 Mon Sep 17 00:00:00 2001 From: Attila Lendvai Date: Tue, 4 Mar 2014 13:49:23 +0600 Subject: [PATCH] Replace DELETE-FROM-PLIST implementation, shorter and faster. Suggested by Stas Boukarev. --- lists.lisp | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/lists.lisp b/lists.lisp index feaa726..502eb71 100644 --- a/lists.lisp +++ b/lists.lisp @@ -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.") -- 2.11.4.GIT