Commits

Peter Szilagyi committed c3ae6a6

fixed a performance bug that slowed C-c C-l when there are lots of errors
and prevents Emacs from hammering OMake Server so much

Comments (0)

Files changed (4)

 =========
 - don't assume the omake status buffer exists when creating the omake
   projects buffer, so C-c C-p works when there's no status buffer
+- fixed a performance bug that slowed C-c C-l when there are lots of
+  errors and prevents Emacs from hammering OMake Server so much
 
 ================================================================================
 2013-01-09 Rolled rev 7b6fc09692cf to test

elisp/jane/jane-string.el

 
 (defun String.eval (s)
   "Eval a string as code"
-  (with-temp-buffer (insert s) (eval-buffer)))
+  (eval (read-from-whole-string s)))
 ;; Can't test.  Always returns nil.
 
 (defun String.escape-quotes (s)

elisp/omake/omake-filter.el

     s))
 
 (defun Omake.Filter.debug-p (s)
-  (when (>= (length s) Omake.Filter.debug-prefix-len)
-    (equal Omake.Filter.debug-prefix
-           (substring s 0 Omake.Filter.debug-prefix-len))))
+  (string-prefix-p Omake.Filter.debug-prefix s))
 
 (defconst Omake.Filter.event-prefix "[event]"
   "prefix attached by the server to indicate an event line")
   (length Omake.Filter.event-prefix))
 
 (defun Omake.Filter.event-p (s)
-  (when (>= (length s) Omake.Filter.event-prefix-len)
-    (equal Omake.Filter.event-prefix
-           (substring s 0 Omake.Filter.event-prefix-len))))
+  (string-prefix-p Omake.Filter.event-prefix s))
 ;; (Omake.Filter.event-p "[event] abc")
 
 (defun Omake.Filter.handle-complete-line (l)

elisp/omake/omake-setup.el

   "When a user kills the status buffer, stop watching the project."
   ;; If the server is dead, allow anything to be killed
   (condition-case _
-      (when (Omake.Server.running-p)
-        (when (Omake.Buffer.is-status-buffer (current-buffer))
+      ;; Omake.Server.running-p is really expensive, because it runs a
+      ;; command.  Check the buffer name first.
+
+      ;; CR pszilagyi: This should really not be a global
+      ;; kill-buffer-hook.  Then it gets called on all buffers, like
+      ;; temporary buffers created by all manner of Emacs built-in
+      ;; functions.  We should only install this hook locally in
+      ;; buffers where it might apply, like omake-mode.
+      (when (Omake.Buffer.is-status-buffer (current-buffer))
+        (when (Omake.Server.running-p)
           (Omake.Model.unwatch (Omake.Id.current))
           t))
       (error t)))