[slime-cvs] CVS slime

CVS User sboukarev sboukarev at common-lisp.net
Fri Aug 20 03:42:52 UTC 2010


Update of /project/slime/cvsroot/slime
In directory cl-net:/tmp/cvs-serv12626

Modified Files:
	ChangeLog slime.el 
Log Message:
(slime-search-buffer-package): Cache the package, searching every time
on large buffers may be slow.


--- /project/slime/cvsroot/slime/ChangeLog	2010/08/20 02:48:18	1.2126
+++ /project/slime/cvsroot/slime/ChangeLog	2010/08/20 03:42:52	1.2127
@@ -3,6 +3,8 @@
 	* slime.el (slime-maybe-complete-as-filename): Limit backward
 	search for #\", it slows down on large buffers.
 	Reported by Raymond Toy.
+	(slime-search-buffer-package): Cache the package, searching every time
+	on large buffers may be slow.
 
 2010-08-15  Stas Boukarev  <stassats at gmail.com>
 
--- /project/slime/cvsroot/slime/slime.el	2010/08/20 02:48:18	1.1332
+++ /project/slime/cvsroot/slime/slime.el	2010/08/20 03:42:52	1.1333
@@ -2095,6 +2095,10 @@
   "Figure out which Lisp package the current buffer is associated with."
   (funcall slime-find-buffer-package-function))
 
+(make-variable-buffer-local
+ (defvar slime-package-cache nil
+   "Cons of the form (buffer-modified-tick . package)"))
+
 ;; When modifing this code consider cases like:
 ;;  (in-package #.*foo*)
 ;;  (in-package #:cl)
@@ -2103,13 +2107,21 @@
 ;;  (in-package |CL|)
 ;;  (in-package #+ansi-cl :cl #-ansi-cl 'lisp)
 (defun slime-search-buffer-package ()
-  (let ((case-fold-search t)
-        (regexp (concat "^(\\(cl:\\|common-lisp:\\)?in-package\\>[ \t']*"
-                        "\\([^)]+\\)[ \t]*)")))
-    (save-excursion
-      (when (or (re-search-backward regexp nil t)
-                (re-search-forward regexp nil t))
-        (match-string-no-properties 2)))))
+  (flet ((search-package ()
+           (let ((case-fold-search t)
+                 (regexp (concat "^(\\(cl:\\|common-lisp:\\)?in-package\\>[ \t']*"
+                                 "\\([^)]+\\)[ \t]*)")))
+             (save-excursion
+               (when (or (re-search-backward regexp nil t)
+                         (re-search-forward regexp nil t))
+                 (match-string-no-properties 2))))))
+    (if (eql (car slime-package-cache) (buffer-modified-tick))
+        (cdr slime-package-cache)
+        (let ((package (search-package)))
+          (setf slime-package-cache
+                (cons (buffer-modified-tick)
+                      package))
+          package))))
 
 ;;; Synchronous requests are implemented in terms of asynchronous
 ;;; ones. We make an asynchronous request with a continuation function





More information about the slime-cvs mailing list