From: Decebal <cldwesterhof@gmail.com>
To: help-gnu-emacs@gnu.org
Subject: Re: How to circumvent warning in batch mode
Date: Sat, 10 Oct 2009 01:50:47 -0700 (PDT) [thread overview]
Message-ID: <fec78cf6-7580-4bea-9e11-64bb951f5825@y21g2000yqn.googlegroups.com> (raw)
In-Reply-To: mailman.8407.1255095844.2239.help-gnu-emacs@gnu.org
On Oct 9, 3:43 pm, Kevin Rodgers <kevin.d.rodg...@gmail.com> wrote:
> > The input file is quite big and I get:
> > File input is large (31MB), really open? (y or n)
> > Is there a way to circumvent this?
>
> let-bind large-file-warning-threshold to nil around the call to find-file.
I allready use:
(switch-to-buffer (find-file-noselect input-file t t))
> > Is there a way to do this more efficient? This script needs about 20
> > seconds. When doing it with a Perl script, it takes about 6 seconds.
>
> 1. Put the code in a file (FILE.el) and byte-compile it. Then instead of
> --eval 'CODE' on the command line, use --load FILE.elc
It is part of a script. So I think the compilation would be faster as
a load from disc. Also: how can I give parameters to an .elc
file?
> 2. It looks like you are doing a lot of unnecessary string allocation with
> concat and substring:
>
> For every character after the first character in the match, you double the
> length of the replacement string until it is at least as long as the length
> of the match string, then you only use the number of characters that were in
> the match string anyway. Change the loop to:
>
> (while (re-search-forward "^ +" nil t)
> (setq match-length (- (point) (match-beginning 0)))
> (if (> match-length 1)
> (replace-match (make-string match-length ?@))
> (replace-match "@")))
Will not work in my case. In the example the replace string is only a
character long, but it could also be for example '1234567890'.
> That could be improved further by caching each replacement string of length
> > 1, so it is only allocated once... But now, I can see that my version
> using make-string does the same amount of string allocation as yours using
> substring, and that your use of concat is infrequent (only needed when the
> match string jumps to a larger length than has been seen so far). So caching
> the replacement string (in an array, indexed by its length) is the way to go.
Making the replacement string longer takes only about a second. The
real work is in the replace-match. Only the coders of Emacs can change
that.
> > Instead of the '@' or chr$(64) I would like to use a nbsp or chr
> > $(160). But then the script needs almost 3 minutes. Also every space
> > is replaced by two characters chr$(194) + chr$(160).
> > What is going wrong here?
>
> In UTF-8, NBSP is 2 bytes: decimal 194 160 aka hex 00C2 00A0.
That explains the two characters, but why does it akes so long?
Because I now use
(switch-to-buffer (find-file-noselect input-file t t))
I do not have this problem anymore.
prev parent reply other threads:[~2009-10-10 8:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-08 23:44 How to circumvent warning in batch mode Decebal
2009-10-09 13:43 ` Kevin Rodgers
2009-10-09 14:42 ` Andreas Politz
[not found] ` <mailman.8415.1255099400.2239.help-gnu-emacs@gnu.org>
2009-10-10 8:23 ` Decebal
[not found] ` <mailman.8407.1255095844.2239.help-gnu-emacs@gnu.org>
2009-10-10 8:50 ` Decebal [this message]
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=fec78cf6-7580-4bea-9e11-64bb951f5825@y21g2000yqn.googlegroups.com \
--to=cldwesterhof@gmail.com \
--cc=help-gnu-emacs@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.
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).