From: Christophe Rhodes Date: Sat, 25 Oct 2014 21:26:31 +0000 (+0100) Subject: slightly better `squeeze-update-state' X-Git-Url: http://christophe.rhodes.io/gitweb/?a=commitdiff_plain;h=35375c87ec7345b3005cb5e70a86ea03e9414695;p=squeeze-el.git slightly better `squeeze-update-state' use a temporary buffer rather than multiple calls to `concat' --- diff --git a/squeeze.el b/squeeze.el index dbab10e..977813b 100644 --- a/squeeze.el +++ b/squeeze.el @@ -39,19 +39,24 @@ (defvar squeeze-control-inhibit-display nil) -(lexical-let ((buffer "")) +(lexical-let ((buffer (get-buffer-create " *squeeze-update-state*"))) (defun squeeze-update-state (string) + ;; FIXME: we could make this a lot more elegant by using the + ;; buffer abstraction more (if (cl-position ?\n string) (let (done-something) - (setq string (concat buffer string)) + (with-current-buffer buffer + (insert string) + (setq string (buffer-string)) + (erase-buffer)) (dolist (line (split-string string "\n")) (when (squeeze-update-state-from-line line) (setq done-something t))) (when done-something (unless squeeze-control-inhibit-display - (squeeze-control-display-players))) - (setq buffer "")) - (setq buffer (concat buffer string))) + (squeeze-control-display-players)))) + (with-current-buffer buffer + (insert string))) string)) (defconst squeeze-player-line-regexp