Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 4 Sep 2004 11:40:25 GMT
From:      Tim Robbins <tjr@freebsd.org>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/71367: regex multibyte support is really slow
Message-ID:  <200409041140.i84BePpC095361@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

The following reply was made to PR bin/71367; it has been noted by GNATS.

From: Tim Robbins <tjr@freebsd.org>
To: "Simon L. Nielsen" <simon@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org, Kuang-che Wu <kcwu@csie.org>
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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200409041140.i84BePpC095361>