diff options
| author | Craig Jennings <c@cjennings.net> | 2026-05-03 20:24:14 -0500 |
|---|---|---|
| committer | Craig Jennings <c@cjennings.net> | 2026-05-03 20:24:14 -0500 |
| commit | ba1a0249bfbc61ba3590ec0c9cd8b5568980ab22 (patch) | |
| tree | 9246df151665b1661b0772284d2b5ade0c381be6 /modules/dashboard-config.el | |
| parent | ff8071ff274342f270de32ac3a8b282b6f75adaa (diff) | |
| download | dotemacs-ba1a0249bfbc61ba3590ec0c9cd8b5568980ab22.tar.gz dotemacs-ba1a0249bfbc61ba3590ec0c9cd8b5568980ab22.zip | |
perf: cache modeline VC data per buffer
The custom modeline's VC `:eval` form was calling `vc-backend`, `vc-working-revision`, `vc-git--symbolic-ref`, and `vc-state` on every redisplay. Mode-line eval runs every keystroke. For a large git repo or a TRAMP buffer over SSH, the round-trip cost shows up as visible input lag.
I split the inline form into helpers and added a buffer-local cache. `cj/modeline-vc-info` returns the cached plist when its TTL hasn't expired and the cache key still matches. The TTL defaults to 5 seconds via `cj/modeline-vc-cache-ttl`. Save and revert hooks invalidate the cache so the user sees state changes promptly. The render path (`cj/modeline-vc-render`) is now a separate function so it can be tested without touching VC at all.
Remote files are skipped by default. `cj/modeline-vc-show-remote` opts back in for cases where TRAMP VC is fast enough to be worth it.
Measured on this repo: uncached reads were about 2.4 ms each, cached reads were about 0.0025 ms each, and remote-skipped reads pay only the cheap `file-remote-p` check.
I added five tests in `tests/test-modeline-config-vc-cache.el`: cache reuse within TTL (backend called once for two reads), refresh after TTL expiry (called twice), remote-file bypass (no backend call, nil result), cache clear (buffer-locals reset to nil), and render output (branch text + face metadata preserved).
Diffstat (limited to 'modules/dashboard-config.el')
0 files changed, 0 insertions, 0 deletions
