From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: Re: PATCH: Re: Associative array ordering and selective unset (Re: Example function)
Date: Thu, 14 Oct 1999 16:15:40 +0000 [thread overview]
Message-ID: <991014161540.ZM21583@candle.brasslantern.com> (raw)
In-Reply-To: <991014150755.ZM21454@candle.brasslantern.com>
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
next prev parent reply other threads:[~1999-10-14 16:15 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1999-10-14 14:25 Sven Wischnowsky
1999-10-14 15:07 ` Bart Schaefer
1999-10-14 16:15 ` Bart Schaefer [this message]
1999-10-15 6:13 Sven Wischnowsky
1999-10-18 9:53 Sven Wischnowsky
1999-10-18 11:12 Sven Wischnowsky
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=991014161540.ZM21583@candle.brasslantern.com \
--to=schaefer@candle.brasslantern.com \
--cc=zsh-workers@sunsite.auc.dk \
/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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
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).