From owner-freebsd-bugs@FreeBSD.ORG Sat Sep 4 11:40:25 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id A595316A4CE for ; Sat, 4 Sep 2004 11:40:25 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 938E443D46 for ; Sat, 4 Sep 2004 11:40:25 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i84BeP16095362 for ; Sat, 4 Sep 2004 11:40:25 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i84BePpC095361; Sat, 4 Sep 2004 11:40:25 GMT (envelope-from gnats) Date: Sat, 4 Sep 2004 11:40:25 GMT Message-Id: <200409041140.i84BePpC095361@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Tim Robbins Subject: Re: bin/71367: regex multibyte support is really slow X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Tim Robbins List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Sep 2004 11:40:25 -0000 The following reply was made to PR bin/71367; it has been noted by GNATS. From: Tim Robbins To: "Simon L. Nielsen" Cc: freebsd-gnats-submit@FreeBSD.org, Kuang-che Wu Subject: Re: bin/71367: regex multibyte support is really slow Date: Sat, 4 Sep 2004 21:36:16 +1000 On Sat, Sep 04, 2004 at 01:21:22PM +0200, Simon L. Nielsen wrote: > On 2004.09.04 10:50:27 +0000, Tim Robbins wrote: > > > >How-To-Repeat: > > > $ cc -O -pipe re.c -o re > > > $ time ./re > > > 7.65 real 7.51 user 0.06 sys > > > I can't reproduce these results. I get: > > I can, more or less.. : > > [simon@zaphod:/tmp] cc -O -pipe re.c -o re > [simon@zaphod:/tmp] /usr/bin/time ./re > 3,85 real 3,54 user 0,12 sys Could you please try this patch? --- lib/libc/regex/regcomp.c.old Sat Sep 4 21:33:53 2004 +++ lib/libc/regex/regcomp.c Sat Sep 4 21:32:50 2004 @@ -1199,13 +1199,15 @@ cset *cs; wint_t ch; { - wint_t *newwides; + wint_t nch, *newwides; assert(ch >= 0); if (ch < NC) { cs->bmp[ch >> 3] |= 1 << (ch & 7); if (cs->icase) { - cs->bmp[towlower(ch) >> 3] |= 1 << (towlower(ch) & 7); - cs->bmp[towupper(ch) >> 3] |= 1 << (towupper(ch) & 7); + if ((nch = towlower(ch)) < NC) + cs->bmp[nch >> 3] |= 1 << (nch & 7); + if ((nch = towupper(ch)) < NC) + cs->bmp[nch >> 3] |= 1 << (nch & 7); } } else { newwides = realloc(cs->wides, (cs->nwides + 1) * @@ -1258,14 +1260,9 @@ wint_t i; wctype_t *newtypes; - for (i = 0; i < NC; i++) { + for (i = 0; i < NC; i++) if (iswctype(i, wct)) CHadd(p, cs, i); - if (cs->icase && i != towlower(i)) - CHadd(p, cs, towlower(i)); - if (cs->icase && i != towupper(i)) - CHadd(p, cs, towupper(i)); - } newtypes = realloc(cs->types, (cs->ntypes + 1) * sizeof(*cs->types)); if (newtypes == NULL) {