unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Richard Stallman <rms@gnu.org>
Cc: ttn@gnu.org, arne@arnested.dk, emacs-devel@gnu.org
Subject: Re: latexenc-find-file-coding-system is slow. (was: Your Emacs changes)
Date: Sun, 01 May 2005 08:07:01 -0400	[thread overview]
Message-ID: <E1DSDDx-0007FA-9r@fencepost.gnu.org> (raw)
In-Reply-To: <87u0lpye89.fsf_-_@xs4all.nl> (message from Lute Kamstra on Fri,  29 Apr 2005 14:11:34 +0200)

    I guess the re-searching in latexenc-find-file-coding-system needs to
    be improved.

It would be faster to search for the strings "\\inputencoding{" and
"\\usepackage\\[" using search-forward, and each time it finds an
occurrence, do string-match at the beginning of the line to see if the
line is a real match.  It would need to do this loop once for each
string.  Such a loop could easily be 100 times faster than the call to
re-search-forward.

   (while (and (not found) (search-forward string nil t))
     (save-excursion
       (beginning-of-line)
       (if (looking-at entire-regexp)
           (setq found (point))))
     (forward-line 1))

There's another way to speed this up, if there is some rule about
where in the file those constructs should occur.  For instance, if the
rule is that they should occur before the first \foo, and \foo is
commonly found in LaTeX files, it could be faster to search first for
\foo, then use the position of the first \foo as a bound in the other
searches.

  parent reply	other threads:[~2005-05-01 12:07 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E1D7MTJ-0002Jj-BJ@fencepost.gnu.org>
2005-04-26 12:07 ` Your Emacs changes Arne Jørgensen
2005-04-28 11:58   ` Thien-Thi Nguyen
2005-04-29 12:11     ` latexenc-find-file-coding-system is slow. (was: Your Emacs changes) Lute Kamstra
2005-04-29 14:57       ` latexenc-find-file-coding-system is slow Arne Jørgensen
2005-04-29 15:48         ` Lute Kamstra
2005-04-29 16:13       ` Stefan Monnier
     [not found]         ` <877jil8rz5.fsf@arnested.dk>
2005-04-29 17:19           ` Lute Kamstra
2005-04-30  8:08       ` David Kastrup
2005-05-01 11:08         ` Lute Kamstra
2005-05-01 12:07       ` Richard Stallman [this message]
     [not found]       ` <871x8m96p6.fsf@arnested.dk>
2005-05-11 11:48         ` Lute Kamstra
2005-05-11 17:21           ` Arne Jørgensen
2005-05-11 23:07             ` Lute Kamstra

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=E1DSDDx-0007FA-9r@fencepost.gnu.org \
    --to=rms@gnu.org \
    --cc=arne@arnested.dk \
    --cc=emacs-devel@gnu.org \
    --cc=ttn@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).