Function: ht-update-with!

ht-update-with! is a byte-compiled function defined in ht.el.

Signature

(ht-update-with! TABLE KEY UPDATER &optional DEFAULT)

Documentation

Update the value of KEY in TABLE with UPDATER.

If the value does not exist, do nothing, unless DEFAULT is non-nil, in which case act as if the value is DEFAULT.

UPDATER receives one argument, the value, and its return value becomes the new value of KEY.

Source Code

;; Defined in ~/.emacs.d/elpa/ht-20230703.558/ht.el
(define-inline ht-update-with! (table key updater &optional default)
  "Update the value of KEY in TABLE with UPDATER.
If the value does not exist, do nothing, unless DEFAULT is
non-nil, in which case act as if the value is DEFAULT.

UPDATER receives one argument, the value, and its return value
becomes the new value of KEY."
  (inline-quote
   (let* ((not-found-symbol (make-symbol "ht--not-found"))
          (v (gethash ,key ,table
                      (or ,default not-found-symbol))))
     (unless (eq v not-found-symbol)
       (prog1 nil
         (puthash ,key (funcall ,updater v) ,table))))))