From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Mario Lang Newsgroups: gmane.emacs.devel Subject: [PATCH] xml.el (xml-parse-string): Use `skip-chars-forward'. Date: Sun, 05 Oct 2008 17:34:17 +0200 Message-ID: <873ajbt5s6.fsf@x2.delysid.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1223226588 5253 80.91.229.12 (5 Oct 2008 17:09:48 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 5 Oct 2008 17:09:48 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Oct 05 19:10:44 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1KmX5N-0001fT-2b for ged-emacs-devel@m.gmane.org; Sun, 05 Oct 2008 19:08:01 +0200 Original-Received: from localhost ([127.0.0.1]:60475 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KmX4J-0005wB-Nn for ged-emacs-devel@m.gmane.org; Sun, 05 Oct 2008 13:06:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KmVca-0002dP-1p for emacs-devel@gnu.org; Sun, 05 Oct 2008 11:34:12 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KmVcY-0002cc-EH for emacs-devel@gnu.org; Sun, 05 Oct 2008 11:34:10 -0400 Original-Received: from [199.232.76.173] (port=40182 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KmVcY-0002cX-49 for emacs-devel@gnu.org; Sun, 05 Oct 2008 11:34:10 -0400 Original-Received: from viefep18-int.chello.at ([213.46.255.22]:43223 helo=viefep16-int.chello.at) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KmVcX-0001R8-Eb for emacs-devel@gnu.org; Sun, 05 Oct 2008 11:34:09 -0400 Original-Received: from edge03.upc.biz ([192.168.13.238]) by viefep16-int.chello.at (InterMail vM.7.08.02.00 201-2186-121-20061213) with ESMTP id <20081005153405.QKMS2059.viefep16-int.chello.at@edge03.upc.biz> for ; Sun, 5 Oct 2008 17:34:05 +0200 Original-Received: from x2.delysid.org ([84.115.136.207]) by edge03.upc.biz with edge id P3a21a05X4UfZvY033a3fU; Sun, 05 Oct 2008 17:34:04 +0200 X-SourceIP: 84.115.136.207 Original-Received: from mlang by x2.delysid.org with local (Exim 4.69) (envelope-from ) id 1KmVcf-00005P-Ez for emacs-devel@gnu.org; Sun, 05 Oct 2008 17:34:17 +0200 User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.2 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Solaris 10 (beta) X-Mailman-Approved-At: Sun, 05 Oct 2008 13:05:51 -0400 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:104345 Archived-At: 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 --=20 CYa, =E2=A1=8D=E2=A0=81=E2=A0=97=E2=A0=8A=E2=A0=95 | Debian Developer .''`. | Get my public key via finger mlang/key@db.debian.org : :' : | 1024D/7FC1A0854909BCCDBE6C102DDFFC022A6B113E44 `. `' `-