From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.io/gmane.emacs.gnus.general/12529 Path: main.gmane.org!not-for-mail From: Greg Stark Newsgroups: gmane.emacs.gnus.general Subject: Re: Yet another washing function. Date: 05 Oct 1997 20:57:31 -0400 Message-ID: References: NNTP-Posting-Host: coloc-standby.netfonds.no X-Trace: main.gmane.org 1035152048 4236 80.91.224.250 (20 Oct 2002 22:14:08 GMT) X-Complaints-To: usenet@main.gmane.org NNTP-Posting-Date: Sun, 20 Oct 2002 22:14:08 +0000 (UTC) Return-Path: Original-Received: from xemacs.org (xemacs.cs.uiuc.edu [128.174.252.16]) by altair.xemacs.org (8.8.7/8.8.7) with ESMTP id TAA07550 for ; Sun, 5 Oct 1997 19:52:39 -0700 Original-Received: from ifi.uio.no (0@ifi.uio.no [129.240.64.2]) by xemacs.org (8.8.5/8.8.5) with SMTP id VAA02503 for ; Sun, 5 Oct 1997 21:45:19 -0500 (CDT) Original-Received: from claymore.vcinet.com (claymore.vcinet.com [208.205.12.23]) by ifi.uio.no with SMTP (8.6.11/ifi2.4) id for ; Mon, 6 Oct 1997 02:57:44 +0200 Original-Received: (qmail 5865 invoked by uid 504); 6 Oct 1997 00:57:43 -0000 Original-Received: (qmail 5862 invoked from network); 6 Oct 1997 00:57:41 -0000 Original-Received: from portF43.Generation.NET (brnstnd@kramden.acf.nyu.edu@205.205.119.23) by claymore.vcinet.com with SMTP; 6 Oct 1997 00:57:41 -0000 Original-Received: by portF43.Generation.NET id m0xI1UK-000AzUC (Debian Smail-3.2 1996-Jul-4 #2); Sun, 5 Oct 1997 20:57:32 -0400 (EDT) Original-To: ding@gnus.org In-Reply-To: Stainless Steel Rat's message of "05 Oct 1997 10:23:48 -0400" Original-Lines: 33 X-Mailer: Gnus v5.4.64/Emacs 19.34 Xref: main.gmane.org gmane.emacs.gnus.general:12529 X-Report-Spam: http://spam.gmane.org/gmane.emacs.gnus.general:12529 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))