Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Kamil Shakirov
alexandria
Commits
048de2e5
Commit
048de2e5
authored
Mar 04, 2014
by
Attila Lendvai
Browse files
Optimize DELETE-FROM-PLIST not to cons.
Patch by "James M. Lawrence" <llmjjmll@gmail.com>
parent
1bb1d834
Changes
1
Hide whitespace changes
Inline
Side-by-side
lists.lisp
View file @
048de2e5
...
...
@@ -278,8 +278,20 @@ not destructively modified. Keys are compared using EQ."
(
defun
delete-from-plist
(
plist
&rest
keys
)
"Just like REMOVE-FROM-PLIST, but this version may destructively modify the
provided plist."
;; FIXME: should not cons
(
apply
'remove-from-plist
plist
keys
))
(
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
)))
(
define-modify-macro
remove-from-plistf
(
&rest
keys
)
remove-from-plist
"Modify macro for REMOVE-FROM-PLIST."
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment