unofficial mirror of emacs-devel@gnu.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

* Re: [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'.
  2008-10-05 15:34 [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward' Mario Lang
@ 2008-10-05 19:04 ` Chong Yidong
  0 siblings, 0 replies; 2+ messages in thread
From: Chong Yidong @ 2008-10-05 19:04 UTC (permalink / raw)
  To: Mario Lang; +Cc: emacs-devel

Mario Lang <mlang@delysid.org> writes:

> * 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:

Nice.  Applied, thanks.




^ 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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).