From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21791 invoked from network); 23 Apr 2005 17:12:26 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 23 Apr 2005 17:12:26 -0000 Received: (qmail 86193 invoked from network); 23 Apr 2005 17:12:20 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 23 Apr 2005 17:12:20 -0000 Received: (qmail 27367 invoked by alias); 23 Apr 2005 17:12:17 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 21167 Received: (qmail 27353 invoked from network); 23 Apr 2005 17:12:16 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 23 Apr 2005 17:12:16 -0000 Received: (qmail 85899 invoked from network); 23 Apr 2005 17:12:16 -0000 Received: from vms040pub.verizon.net (206.46.252.40) by a.mx.sunsite.dk with SMTP; 23 Apr 2005 17:12:09 -0000 Received: from candle.brasslantern.com ([4.11.1.68]) by vms040.mailsrvcs.net (Sun Java System Messaging Server 6.2 HotFix 0.04 (built Dec 24 2004)) with ESMTPA id <0IFE00AT3T48ZCT2@vms040.mailsrvcs.net> for zsh-workers@sunsite.dk; Sat, 23 Apr 2005 12:12:08 -0500 (CDT) Received: from candle.brasslantern.com (IDENT:schaefer@localhost [127.0.0.1]) by candle.brasslantern.com (8.12.11/8.12.11) with ESMTP id j3NHC7wG005143 for ; Sat, 23 Apr 2005 10:12:07 -0700 Received: (from schaefer@localhost) by candle.brasslantern.com (8.12.11/8.12.11/Submit) id j3NHC7rs005142 for zsh-workers@sunsite.dk; Sat, 23 Apr 2005 10:12:07 -0700 Date: Sat, 23 Apr 2005 17:12:06 +0000 From: Bart Schaefer Subject: Re: replacement slowdown In-reply-to: <20050423162635.GA30862@scowler.net> To: zsh-workers@sunsite.dk Message-id: <1050423171206.ZM5141@candle.brasslantern.com> MIME-version: 1.0 X-Mailer: Z-Mail (5.0.0 30July97) Content-type: text/plain; charset=us-ascii References: <20050422232316.GA27665@scowler.net> <1050423031422.ZM3881@candle.brasslantern.com> <20050423031907.GA27233@scowler.net> <1050423160721.ZM4469@candle.brasslantern.com> <20050423162635.GA30862@scowler.net> Comments: In reply to Clint Adams "Re: replacement slowdown" (Apr 23, 12:26pm) X-Spam-Checker-Version: SpamAssassin 3.0.2 on a.mx.sunsite.dk X-Spam-Level: X-Spam-Status: No, score=-2.6 required=6.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.2 X-Spam-Hits: -2.6 On Apr 23, 12:26pm, Clint Adams wrote: } } > What's calling pattryrefs() 28000+ times? Is that how many lines there } > are in /tmp/blah? } } 231 lines, but 57093 chars. pattrylen() seems to be called 57092 times } by igetmatch. OK, that makes sense. igetmatch() has a for() loop that, when asked to find every possible match within the string (e.g. by ${...//...}), calls the pattern comparison once at every possible matching position. Since the pattern is only one character long (/,/), it calls it once for each character in the string. But pattry() recomputes the unmetafied length of the *entire* string on each call. So that length computation is going to have to be factored out of pattry(), possibly by storing it in the Patprog the way that's done for set_pat_start() and set_pat_end(). -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net