[cxml-cvs] CVS cxml/xml

dlichteblau dlichteblau at common-lisp.net
Wed Oct 3 15:21:57 UTC 2007


Update of /project/cxml/cvsroot/cxml/xml
In directory clnet:/tmp/cvs-serv25157

Modified Files:
	xml-parse.lisp 
Log Message:
Fixed time and space usage in cases where entity references
follow each other (thanks to Ivan Shvedunov for the report).

	* xml/xml-parse.lisp (P/CONTENT): Removed useless call to append.
	Use loop instead of tail recursion.


--- /project/cxml/cvsroot/cxml/xml/xml-parse.lisp	2007/08/05 11:15:48	1.72
+++ /project/cxml/cvsroot/cxml/xml/xml-parse.lisp	2007/10/03 15:21:56	1.73
@@ -2800,45 +2800,39 @@
 
 (defun p/content (input)
   ;; [43] content ::= (element | CharData | Reference | CDSect | PI | Comment)*
-  (multiple-value-bind (cat sem) (peek-token input)
-    (case cat
-      ((:stag :ztag)
-       (p/element input)
-       (p/content input))
-      ((:CDATA)
-       (process-characters input sem)
-       (sax:characters (handler *ctx*) sem)
-       (p/content input))
-      ((:ENTITY-REF)
-       (let ((name sem))
-         (consume-token input)
-         (append
-          (recurse-on-entity input name :general
-                             (lambda (input)
-                               (prog1
-                                   (etypecase (checked-get-entdef name :general)
-                                     (internal-entdef (p/content input))
-                                     (external-entdef (p/ext-parsed-ent input)))
-                                 (unless (eq (peek-token input) :eof)
-                                   (wf-error input "Trailing garbage. - ~S"
-					     (peek-token input))))))
-          (p/content input))))
-      ((:<!\[)
-       (let ((data (process-cdata-section input)))
-	 (sax:start-cdata (handler *ctx*))
-	 (sax:characters (handler *ctx*) data)
-	 (sax:end-cdata (handler *ctx*)))
-       (p/content input))
-      ((:PI)
-       (consume-token input)
-       (sax:processing-instruction (handler *ctx*) (car sem) (cdr sem))
-       (p/content input))
-      ((:COMMENT)
-       (consume-token input)
-       (sax:comment (handler *ctx*) sem)
-       (p/content input))
-      (otherwise
-       nil))))
+  (loop
+     (multiple-value-bind (cat sem) (peek-token input)
+       (case cat
+	 ((:stag :ztag)
+	  (p/element input))
+	 ((:CDATA)
+	  (process-characters input sem)
+	  (sax:characters (handler *ctx*) sem))
+	 ((:ENTITY-REF)
+	  (let ((name sem))
+	    (consume-token input)
+	    (recurse-on-entity input name :general
+			       (lambda (input)
+				 (prog1
+				     (etypecase (checked-get-entdef name :general)
+				       (internal-entdef (p/content input))
+				       (external-entdef (p/ext-parsed-ent input)))
+				   (unless (eq (peek-token input) :eof)
+				     (wf-error input "Trailing garbage. - ~S"
+					       (peek-token input))))))))
+	 ((:<!\[)
+	  (let ((data (process-cdata-section input)))
+	    (sax:start-cdata (handler *ctx*))
+	    (sax:characters (handler *ctx*) data)
+	    (sax:end-cdata (handler *ctx*))))
+	 ((:PI)
+	  (consume-token input)
+	  (sax:processing-instruction (handler *ctx*) (car sem) (cdr sem)))
+	 ((:COMMENT)
+	  (consume-token input)
+	  (sax:comment (handler *ctx*) sem))
+	 (otherwise
+	  (return))))))
 
 ;; [78] extParsedEnt ::= TextDecl? contentw
 ;; [79]        extPE ::= TextDecl? extSubsetDecl




More information about the Cxml-cvs mailing list