From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3547 invoked from network); 14 Apr 2000 12:15:41 -0000 Received: from sunsite.auc.dk (130.225.51.30) by ns1.primenet.com.au with SMTP; 14 Apr 2000 12:15:41 -0000 Received: (qmail 17019 invoked by alias); 14 Apr 2000 12:15:34 -0000 Mailing-List: contact zsh-workers-help@sunsite.auc.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 10759 Received: (qmail 17005 invoked from network); 14 Apr 2000 12:15:34 -0000 Date: Fri, 14 Apr 2000 13:15:00 +0100 From: Peter Stephenson Subject: Re: PATCH: fix for (#s) and (#e) in param substs In-reply-to: "Your message of Fri, 14 Apr 2000 15:42:05 +0400." <000601bfa606$750527f0$21c9ca95@mow.siemens.ru> To: zsh-workers@sunsite.auc.dk (Zsh hackers list) Message-id: <0FT000MMUA0ZD3@la-la.cambridgesiliconradio.com> Content-transfer-encoding: 7BIT > Just a question - is there any speed penalty in using / instead of # or > %? There will be some effect, since there is no optimisation to look for an initial (#s) or final (#e) in the parameter substitution code, unlike # and % where the start/end anchor is hard-coded. I had to think about this... Ksh form Form with explicit anchors ${..#..} ${(S)../(#s)..} ${..##..} ${../(#s)..} In the second form in each case, we still advance up the string looking for matches, so it's slower, particularly for a long test string. However, the test will always fail on the first attempt, so it doesn't depend on the complexity of the pattern after the anchor. ${..%%..} ${../..(#e)} Not much difference, since in the former case we march up the string until we find a match, pretty much as in the second case. ${..%..} ${(S)../..(#e)} These could be quite a lot slower with a fixed tail for a long string, e.g. ${(S)foo/.c(#e)} where $foo is long, since that has to march up the string to find a match, then shorten from the end (though the latter will always fail on the second match so isn't really a problem). But with a fixed string you wouldn't bother with the (S) parameter flag. Anyway, I'd be interested to hear if you can notice any difference using /. It wouldn't be that hard to do special cases. I don't know if it's worth it. I expect these bits are only going to be used by the real zsh nutcases :-). -- Peter Stephenson Cambridge Silicon Radio, Unit 300, Science Park, Milton Road, Cambridge, CB4 0XL, UK Tel: +44 (0)1223 392070