From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6421 invoked from network); 14 Oct 1999 16:15:52 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Oct 1999 16:15:52 -0000 Received: (qmail 6580 invoked by alias); 14 Oct 1999 16:15:46 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 8259 Received: (qmail 6570 invoked from network); 14 Oct 1999 16:15:44 -0000 From: "Bart Schaefer" Message-Id: <991014161540.ZM21583@candle.brasslantern.com> Date: Thu, 14 Oct 1999 16:15:40 +0000 In-Reply-To: <991014150755.ZM21454@candle.brasslantern.com> Comments: In reply to "Bart Schaefer" "Re: PATCH: Re: Associative array ordering and selective unset (Re: Example function)" (Oct 14, 3:07pm) References: <199910141425.QAA16346@beta.informatik.hu-berlin.de> <991014150755.ZM21454@candle.brasslantern.com> X-Mailer: Z-Mail (5.0.0 30July97) To: zsh-workers@sunsite.auc.dk Subject: Re: PATCH: Re: Associative array ordering and selective unset (Re: Example function) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Oct 14, 3:07pm, Bart Schaefer wrote: } Subject: Re: PATCH: Re: Associative array ordering and selective unset (Re } } } scanparamvals(HashNode hn, int flags) } } { } } + if (!(prog = patcompile(tmp, 0, NULL)) || !pattry(prog, scanstr)) } } + return; } } It just seemed so unpleasant to recompile the pattern for every key ... I should probably clarify what I mean by that. In another post, I wrote: map=( '(*.(gz|Z)) zcat' '(*.bz2) bzip2 -dc' '(*.bz) bzip -dc' '(*) <' ) eval 'for i do case $i in' ${(j( $i;; ))map} '$i;; esac done' Note that with this trick, all the patterns get compiled once (when the `case' is parsed) and then we can compare every $i to the "keys" without recompiling any patterns. Thus the above is going to be significantly more efficient than: typeset -A map map=( '(*.(gz|Z))' 'zcat' '(*.bz2)' 'bzip2 -dc' '(*.bz)' 'bzip -dc' '(*)' '<' ) for i do eval $map[(k)$i] $i; done But this is not to suggest we shouldn't keep Sven's patch. -- Bart Schaefer Brass Lantern Enterprises http://www.well.com/user/barts http://www.brasslantern.com