Function: c-laomib-put-cache

c-laomib-put-cache is a byte-compiled function defined in cc-engine.el.gz.

Signature

(c-laomib-put-cache LIM START END RESULT)

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/cc-engine.el.gz
(defun c-laomib-put-cache (lim start end result)
  ;; Insert a new element into `c-laomib-cache', removing another element to
  ;; make room, if necessary.  The four parameters LIM, START, END, RESULT are
  ;; the components of the new element (see comment for `c-laomib-cache').
  ;; The return value is of no significance.
  (when lim
    (let (old-elt
	  (new-elt (list lim start end result))
	  (cur-ptr c-laomib-cache)
	  size)

      ;; If there is an elt which overlaps with the new element, remove it.
      (while (and (setq old-elt (assq lim cur-ptr))
		  (not (and (> start (car (cddr old-elt)))
			    (<= start (cadr old-elt)))))
	(setq cur-ptr (cdr (memq old-elt cur-ptr))))
      (when (and cur-ptr old-elt)
	(setq c-laomib-cache (delq old-elt c-laomib-cache)))

      ;; Don't let the cache grow indefinitely.
      (cond
       ((fboundp 'ntake)		; >= Emacs 29.1
	(setq c-laomib-cache (ntake 49 c-laomib-cache)))
       ((>= (setq size (length c-laomib-cache)) 50)
	(setq c-laomib-cache (butlast c-laomib-cache (- size 49)))))
    (push new-elt c-laomib-cache))))