emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'.


From: Mario Lang
Subject: [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'.
Date: Sun, 05 Oct 2008 17:34:17 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux)

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/address@hidden
 : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44
 `. `'
   `-      <URL:http://delysid.org/>  <URL:http://www.staff.tugraz.at/mlang/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]