From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 12654 invoked from network); 21 Sep 2006 20:03:08 -0000 X-Spam-Checker-Version: SpamAssassin 3.1.5 (2006-08-29) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=AWL,BAYES_00, FORGED_RCVD_HELO autolearn=ham version=3.1.5 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 21 Sep 2006 20:03:08 -0000 Received-SPF: none (ns1.primenet.com.au: domain at sunsite.dk does not designate permitted sender hosts) Received: (qmail 97890 invoked from network); 21 Sep 2006 20:03:02 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 21 Sep 2006 20:03:01 -0000 Received: (qmail 2433 invoked by alias); 21 Sep 2006 20:02:58 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 22757 Received: (qmail 2423 invoked from network); 21 Sep 2006 20:02:56 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 21 Sep 2006 20:02:56 -0000 Received: (qmail 97543 invoked from network); 21 Sep 2006 20:02:56 -0000 Received: from mtaout01-winn.ispmail.ntl.com (81.103.221.47) by a.mx.sunsite.dk with SMTP; 21 Sep 2006 20:02:54 -0000 Received: from aamtaout02-winn.ispmail.ntl.com ([81.103.221.35]) by mtaout01-winn.ispmail.ntl.com with ESMTP id <20060921200253.KZCA15018.mtaout01-winn.ispmail.ntl.com@aamtaout02-winn.ispmail.ntl.com> for ; Thu, 21 Sep 2006 21:02:53 +0100 Received: from pwslaptop.csr.com ([81.107.41.155]) by aamtaout02-winn.ispmail.ntl.com with SMTP id <20060921200253.GZZE23938.aamtaout02-winn.ispmail.ntl.com@pwslaptop.csr.com> for ; Thu, 21 Sep 2006 21:02:53 +0100 Date: Thu, 21 Sep 2006 21:02:51 +0100 From: Peter Stephenson To: zsh-workers@sunsite.dk Subject: Re: PATCH: Re: Broken completion with UTF-8 description Message-Id: <20060921210251.8d84fdb1.p.w.stephenson@ntlworld.com> In-Reply-To: <200609212104.23198.arvidjaar@newmail.ru> References: <200609171853.57050.arvidjaar@newmail.ru> <20060917201612.fe9933d5.p.w.stephenson@ntlworld.com> <200609212104.23198.arvidjaar@newmail.ru> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.20; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Thu, 21 Sep 2006 21:04:17 +0400 Andrey Borzenkov wrote: > static int > cd_sort(const void *a, const void *b) > { > - - return strcmp((*((Cdstr *) a))->str, (*((Cdstr *) b))->str); > + char *as = ztrdup((*((Cdstr *) a))->str); > + int aslen = strlen(as); > + char *bs = ztrdup((*((Cdstr *) b))->str); > + int bslen = strlen(bs); > + int ret; > + > + unmetafy(as, &ret); > + unmetafy(bs, &ret); > + ret = strpcmp(&as, &bs); > + zfree(as, aslen); > + zfree(bs, bslen); > + return ret; > } Looking in more detail, cd_sort is passed as an argument to qsort(), so it may be called many times while sorting the arguments. It's therefore probably better to do the conversion in the caller, of which there's only one at line 270, i.e. the str elements of the values in the array grps should be copied to an array of unmetafied strings, and then simply call strpcmp() in cd_sort. In fact, since you're doing a copy anyway you could probably convert the array to a format where you can pass strpcmp() as the final argument and eliminate cd_sort() altogether. That ought to improve your speed problem quite a bit. -- Peter Stephenson Web page now at http://homepage.ntlworld.com/p.w.stephenson/