[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
mode-line-eol-desc needs to use assoc, not assq
From: |
Ami Fischman |
Subject: |
mode-line-eol-desc needs to use assoc, not assq |
Date: |
Fri, 19 Dec 2008 23:11:31 -0800 |
mode-line-eol-desc uses assq to look up desc in
mode-line-eol-desc-cache, but the key used is computed by
coding-system-eol-type which returns a vector sometimes. This results
in mode-line-eol-desc-cache growing without bounds over the lifetime
of an emacs process. Changing mode-line-eol-desc to use assoc instead
of assq (so that the vectors are compared with equal and so have a
chance of returning t) fixes this.
Repro:
$ emacs -Q
eval (length mode-line-eol-desc-cache)
do this many times, the value is always 1.
eval (prefer-coding-system 'utf-8-emacs)
eval (length mode-line-eol-desc-cache)
do this many times; the value keeps increasing by 1 on every call(!).
C-h v mode-line-eol-desc-cache RET
eval (length mode-line-eol-desc-cache)
witness the returned value increasing by 3 for every C-h v
(describe-variable) as above.
Many innocuous actions such as visiting files and creating buffers
will cause this variable to grow with many many duplicate entries.
Drive the variable arbitrarily high by evaling:
(progn
(dotimes (j 1000)
(switch-to-buffer "does-not-exist")
(kill-buffer)
(redisplay))
(insert (format "%d " (length mode-line-eol-desc-cache))))
In an emacs running for several days I've seen the variable get over
420,000 entries in it, according to prin1-to-string.
Making the s/assq/assoc/ change as above fixes all these repro cases.
-a
- mode-line-eol-desc needs to use assoc, not assq,
Ami Fischman <=