Gnus development mailing list
 help / color / mirror / Atom feed
From: Greg Stark <gsstark@MIT.EDU>
Subject: Re: Yet another washing function.
Date: 05 Oct 1997 20:57:31 -0400	[thread overview]
Message-ID: <ycqpvpjg138.fsf@portD19.generation.net> (raw)
In-Reply-To: Stainless Steel Rat's message of "05 Oct 1997 10:23:48 -0400"


Please try to avoid generating garbage whenever possible, the regular
expression functions generate a lot of wasted memory and the loops in elisp
are very inefficient compared to using primitives that do loops in C. Also,
replace-match probably moves the gap to that point which means you're doing
the equivalent of memoving the entire article a small bit at a time. 

I've noticed that article washing is a noticeable delay. It might be worth
looking through the existing washing functions for code that generates excess
garbage, do loops in elisp that can be done in C with primitives, or move the
gap unecessarily. Here's an implementation that does none of these:

(subst-char-in-region (point-min) (point-max) ?\221 ?`)
(subst-char-in-region (point-min) (point-max) ?\222 ?')
(subst-char-in-region (point-min) (point-max) ?\223 ?\")
(subst-char-in-region (point-min) (point-max) ?\224 ?\")

An even better alternative might be to use translate-region but it's a bit
awkward and likely to cause problems with XEmacs 20 and Emacs 20 where
characters and integers are distinct. It may not actually be faster than a few
loops through the text, though i'm not sure if the break-even point would be
more or less than four.

(let ((x (make-string 225 ?x))
      (i -1))
  (while (< (incf i) (length x))
    (aset x i i))
  (aset x ?\221 ?`)
  (aset x ?\222 ?')
  (aset x ?\223 ?\")
  (aset x ?\224 ?\")
  x
  (translate-region (point-min) (point-max) x))


  parent reply	other threads:[~1997-10-06  0:57 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-05  0:47 St. Suika Roberts
1997-10-05 11:27 ` Kim-Minh Kaplan
     [not found] ` <x7iuvc8f0r.fsf@peorth.gweep.net>
1997-10-06  0:57   ` Greg Stark [this message]
1997-10-08 16:23     ` Lars Balker Rasmussen
1997-11-13 18:06       ` Lars Balker Rasmussen
1997-11-13 21:37         ` Lars Magne Ingebrigtsen
1997-10-06 19:57 ` William M. Perry
1997-10-07 14:06 ` Michael Welsh Duggan
1997-10-12 14:53 ` Lars Magne Ingebrigtsen

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ycqpvpjg138.fsf@portD19.generation.net \
    --to=gsstark@mit.edu \
    /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 NNTP newsgroup(s).