[climacs-cvs] CVS update: climacs/syntax.lisp

Robert Strandh rstrandh at common-lisp.net
Fri Apr 15 05:02:54 UTC 2005


Update of /project/climacs/cvsroot/climacs
In directory common-lisp.net:/tmp/cvs-serv22111

Modified Files:
	syntax.lisp 
Log Message:
Performance improvement of the Earley parser.  handle-item is no
longer called on nil items which represented the vast majority of
calls.


Date: Fri Apr 15 07:02:53 2005
Author: rstrandh

Index: climacs/syntax.lisp
diff -u climacs/syntax.lisp:1.42 climacs/syntax.lisp:1.43
--- climacs/syntax.lisp:1.42	Thu Apr 14 10:13:18 2005
+++ climacs/syntax.lisp	Fri Apr 15 07:02:53 2005
@@ -372,8 +372,9 @@
     (flet ((handle-parse-tree ()
 	     (map-over-incomplete-items from-state
 	       (lambda (orig-state incomplete-item)
-		 (handle-item (derive-item incomplete-item parse-tree)
-			      orig-state to-state)))))
+		 (let ((new-item (derive-item incomplete-item parse-tree)))
+		   (when new-item 
+		     (handle-item new-item orig-state to-state)))))))
       (cond ((find parse-tree (gethash from-state parse-trees)
 		   :test #'parse-tree-better)
 	     (setf (gethash from-state parse-trees)
@@ -387,9 +388,6 @@
 	    (t (push parse-tree (gethash from-state parse-trees))
 	       (handle-parse-tree))))))
 
-(defmethod handle-item ((item (eql nil)) orig-state to-state)
-  nil)
-
 (defmethod handle-item ((item incomplete-item) orig-state to-state)
   (declare (optimize speed))
   (cond ((find item (the list (gethash orig-state (incomplete-items to-state)))
@@ -410,8 +408,8 @@
 					   :parse-tree (right-hand-side rule)))
 			to-state to-state))
 	 (loop for parse-tree in (gethash to-state (parse-trees to-state))
- 	       do (handle-item (derive-item item parse-tree)
-			       to-state to-state)))))
+ 	       do (let ((new-item (derive-item item parse-tree)))
+		    (when new-item (handle-item new-item to-state to-state)))))))
 
 (defmethod handle-item ((item complete-item) orig-state to-state)
   (potentially-handle-parse-tree (parse-tree item) orig-state to-state))




More information about the Climacs-cvs mailing list