[slime-cvs] CVS slime

bdowning bdowning at common-lisp.net
Thu May 25 03:15:20 UTC 2006


Update of /project/slime/cvsroot/slime
In directory clnet:/tmp/cvs-serv6750

Modified Files:
	swank.lisp ChangeLog 
Log Message:
* swank.lisp (recursively-compute-most-completions & friends):
  Micro-optimize the fuzzy completion engine, improving performace
  by a factor of about 4 on SBCL.  However, it will only work on
  simple-strings now, and CHAR= is burned in instead of being an
  option.  I don't think this is too much of a limitation.  At this
  point rendering the results on the emacs side takes much longer
  than finding them for long result lists.


--- /project/slime/cvsroot/slime/swank.lisp	2006/05/12 12:21:45	1.378
+++ /project/slime/cvsroot/slime/swank.lisp	2006/05/25 03:15:20	1.379
@@ -3192,7 +3192,7 @@
              (and (or (not external)
                       (symbol-external-p symbol package))
                   (compute-highest-scoring-completion 
-                   string (funcall converter (symbol-name symbol)) #'char=))))
+                   string (funcall converter (symbol-name symbol))))))
       (do-symbols (symbol package)
         (if (string= "" string)
             (when (or (and external (symbol-external-p symbol package))
@@ -3214,7 +3214,7 @@
                                           ":")
           for (result score) = (multiple-value-list
                                 (compute-highest-scoring-completion
-                                 name package-name #'char=))
+                                 name package-name))
           if result collect (list package-name score result))))
 
 (defslimefun fuzzy-completion-selected (original-string completion)
@@ -3241,37 +3241,38 @@
 
 Most natural language searches and symbols do not have this
 problem -- this is only here as a safeguard.")
+(declaim (fixnum *fuzzy-recursion-soft-limit*))
 
-(defun compute-highest-scoring-completion (short full test)
+(defun compute-highest-scoring-completion (short full)
   "Finds the highest scoring way to complete the abbreviation
-SHORT onto the string FULL, using TEST as a equality function for
+SHORT onto the string FULL, using CHAR= as a equality function for
 letters.  Returns two values:  The first being the completion
 chunks of the high scorer, and the second being the score."
   (let* ((scored-results
           (mapcar #'(lambda (result)
                       (cons (score-completion result short full) result))
-                  (compute-most-completions short full test)))
+                  (compute-most-completions short full)))
          (winner (first (sort scored-results #'> :key #'first))))
     (values (rest winner) (first winner))))
 
-(defun compute-most-completions (short full test)
+(defun compute-most-completions (short full)
   "Finds most possible ways to complete FULL with the letters in SHORT.
 Calls RECURSIVELY-COMPUTE-MOST-COMPLETIONS recursively.  Returns
 a list of (&rest CHUNKS), where each CHUNKS is a description of
 how a completion matches."
   (let ((*all-chunks* nil))
     (declare (special *all-chunks*))
-    (recursively-compute-most-completions short full test 0 0 nil nil nil t)
+    (recursively-compute-most-completions short full 0 0 nil nil nil t)
     *all-chunks*))
 
 (defun recursively-compute-most-completions 
-    (short full test 
+    (short full 
      short-index initial-full-index 
      chunks current-chunk current-chunk-pos 
      recurse-p)
   "Recursively (if RECURSE-P is true) find /most/ possible ways
-to fuzzily map the letters in SHORT onto FULL, with TEST being a
-function to determine if two letters match.
+to fuzzily map the letters in SHORT onto FULL, using CHAR= to
+determine if two letters match.
 
 A chunk is a list of elements that have matched consecutively.
 When consecutive matches stop, it is coerced into a string,
@@ -3287,7 +3288,10 @@
 
 Once a word has been completely matched, the chunks are pushed
 onto the special variable *ALL-CHUNKS* and the function returns."
-  (declare (special *all-chunks*))
+  (declare (optimize speed)
+           (fixnum short-index initial-full-index)
+           (simple-string short full)
+           (special *all-chunks*))
   (flet ((short-cur () 
            "Returns the next letter from the abbreviation, or NIL
             if all have been used."
@@ -3316,13 +3320,13 @@
         ((= pos (length full)))
       (let ((cur-char (aref full pos)))
         (if (and (short-cur) 
-                 (funcall test cur-char (short-cur)))
+                 (char= cur-char (short-cur)))
             (progn
               (when recurse-p
                 ;; Try other possibilities, limiting insanely deep
                 ;; recursion somewhat.
                 (recursively-compute-most-completions 
-                 short full test short-index (1+ pos) 
+                 short full short-index (1+ pos) 
                  chunks current-chunk current-chunk-pos
                  (not (> (length *all-chunks*) 
                          *fuzzy-recursion-soft-limit*))))
--- /project/slime/cvsroot/slime/ChangeLog	2006/05/24 21:26:19	1.897
+++ /project/slime/cvsroot/slime/ChangeLog	2006/05/25 03:15:20	1.898
@@ -1,3 +1,13 @@
+2006-05-24  Brian Downing  <bdowning at lavos.net>
+
+	* swank.lisp (recursively-compute-most-completions & friends):
+	Micro-optimize the fuzzy completion engine, improving performace
+	by a factor of about 4 on SBCL.  However, it will only work on
+	simple-strings now, and CHAR= is burned in instead of being an
+	option.  I don't think this is too much of a limitation.  At this
+	point rendering the results on the emacs side takes much longer
+	than finding them for long result lists.
+
 2006-05-24  Alan Ruttenberg <alanr-l at mumble.net>
 	* swank-abcl: Add some more mop functions to you can inspect classes,
 	generic functions, methods, slots.




More information about the slime-cvs mailing list