all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'.
@ 2008-10-05 15:34 Mario Lang
  2008-10-05 19:04 ` Chong Yidong
  0 siblings, 1 reply; 2+ messages in thread
From: Mario Lang @ 2008-10-05 15:34 UTC (permalink / raw)
  To: emacs-devel

Hi.

        * xml.el (xml-parse-string): Use `skip-chars-forward' instead
        of `search-forward' followed by `backward-char'.

This change gives me a significant speedup of XML parsing with xml.el:

Current HEAD:
Function Name                    Call Count  Elapsed Time  Average Time
xml-parse-region                 3           946.16447599  315.38815866
xml-parse-string                 190278      322.59048899  0.0016953640

With this change applied:
Function Name                    Call Count  Elapsed Time  Average Time
xml-parse-region                 3           637.16046399  212.38682133
xml-parse-string                 190278      7.1974619999  3.782...e-05

Yes, I didn't believe it either on first sight, so I repeated my test
a few times.  Its always the same, XML parsing is 30% faster with
this small patch applied!

--- a/lisp/xml.el
+++ b/lisp/xml.el
@@ -494,9 +494,7 @@ Returns one of:
 (defun xml-parse-string ()
   "Parse the next whatever.  Could be a string, or an element."
   (let* ((pos (point))
-	 (string (progn (if (search-forward "<" nil t)
-			    (forward-char -1)
-			  (goto-char (point-max)))
+	 (string (progn (skip-chars-forward "^<")
 			(buffer-substring-no-properties pos (point)))))
     ;; Clean up the string.  As per XML specifications, the XML
     ;; processor should always pass the whole string to the

-- 
CYa,
  ⡍⠁⠗⠊⠕ | Debian Developer <URL:http://debian.org/>
  .''`. | Get my public key via finger mlang/key@db.debian.org
 : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44
 `. `'
   `-      <URL:http://delysid.org/>  <URL:http://www.staff.tugraz.at/mlang/>




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-10-05 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-05 15:34 [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward' Mario Lang
2008-10-05 19:04 ` Chong Yidong

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.