Function: jsonrpc--limit-buffer-size

jsonrpc--limit-buffer-size is a byte-compiled function defined in jsonrpc.el.gz.

Signature

(jsonrpc--limit-buffer-size MAX-SIZE)

Documentation

Limit the current buffer to MAX-SIZE by eating lines at the beginning.

Do nothing if MAX-SIZE is nil.

Source Code

;; Defined in /usr/src/emacs/lisp/jsonrpc.el.gz
(defun jsonrpc--limit-buffer-size (max-size)
  "Limit the current buffer to MAX-SIZE by eating lines at the beginning.
Do nothing if MAX-SIZE is nil."
  (when max-size
    (while (> (buffer-size) max-size)
      (delete-region
       (point-min)
       (save-excursion
         ;; Remove 1/4, so that the cost is O(1) amortized, since each
         ;; call to `delete-region' will move the buffer contents twice.
         (goto-char (+ (point-min) (/ (buffer-size) 4)))
         (forward-line)
         (point))))))