This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][BZ #15346] Allow leading and trailing spaces in getdate


On Mon, Apr 08, 2013 at 05:21:22PM -0400, Rich Felker wrote:
> On Mon, Apr 08, 2013 at 01:12:56PM -0700, Roland McGrath wrote:
> > > +  /* Skip leading spaces.  */
> > 
> > s/spaces/whitespace/
> > 
> > > +  while (string[i] && isspace (string[i]))
> > > +    i++;
> > 
> > Avoid Boolean coercion: string[i] != '\0'.
> > But since you've already done strlen, why not i < inlen?
> 
> I don't think it matters here, but in general the idiom of testing for
> a zero byte is superior to comparing against the length, because it
> involves one fewer variables (and thus less register pressure) in the
> loop.
> 
It does not matter here. But string[i] != '\0' is retundant because
whitespaces are nonzero.

For optimizing (isspace (string[i]) i++; pattern major obstackle is
dependence on locale.
Second problem is that this loops usualy matches 0/1 spaces.
This makes call cost relatively expensive when it causes spills.

I could speed up this by optimizing isspace to locale dependent table
lookup. 

I did not suggest it yet as it changes ABI. 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]