1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-12 06:41:13 +02:00

Optimize `vhash-delete'.

* module/ice-9/vlist.scm (vhash-delete): Check whether KEY is in VHASH
  and return VHASH if it's not.
This commit is contained in:
Ludovic Courtès 2011-02-22 00:08:39 +01:00
parent 8bc5b79df7
commit 2a39def1a8

View file

@ -530,6 +530,7 @@ value of @var{result} for the first call to @var{proc}."
(define* (vhash-delete key vhash #:optional (equal? equal?) (hash hash))
"Remove all associations from @var{vhash} with @var{key}, comparing keys
with @var{equal?}."
(if (vhash-assoc key vhash equal? hash)
(vlist-fold (lambda (k+v result)
(let ((k (car k+v))
(v (cdr k+v)))
@ -537,6 +538,7 @@ with @var{equal?}."
result
(vhash-cons k v result))))
vlist-null
vhash)
vhash))
(define vhash-delq (cut vhash-delete <> <> eq? hashq))