From: Mario Lang <mlang@delysid.org>
To: emacs-devel@gnu.org
Subject: [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'.
Date: Sun, 05 Oct 2008 17:34:17 +0200 [thread overview]
Message-ID: <873ajbt5s6.fsf@x2.delysid.org> (raw)
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/>
next reply other threads:[~2008-10-05 15:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-05 15:34 Mario Lang [this message]
2008-10-05 19:04 ` [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward' Chong Yidong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=873ajbt5s6.fsf@x2.delysid.org \
--to=mlang@delysid.org \
--cc=emacs-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).