Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: PATCH: Re: Associative array ordering and selective unset (Re: Example function)



Bart Schaefer wrote:

> I almost implemented this a while ago, but I stopped because of this:
> 
> }  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 ...

Yep, I was a bit worried about this, too.

> 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.

I had forgotten this message (and had the `(q)' thing in my todo list
and some spare time between holding exams).

Anyway, this reminds me that we still haven't tried to store
pre-compiled patterns in the execution trees for `case' and
`[[ .. = ..]]'...

Bye
 Sven


--
Sven Wischnowsky                         wischnow@xxxxxxxxxxxxxxxxxxxxxxx



Messages sorted by: Reverse Date, Date, Thread, Author