strcspn(3) complexity improvement

Matthew Dillon dillon at apollo.backplane.com
Tue Apr 5 20:46:51 PDT 2005


:The real question I have is, how long does the string need to be before
:this is a win and how much does it hurt for typical string lengths?
:I've written code with strcspn that needed to perform well, but it was
:parsing 80-column punch card derived formats.
:
:-- Brooks

     I think the answer is to not use strcspn() in cases where it *really*
     matters.

     I don't think what's in DFly is the right solution either.  A bitmap
     would be a good compromise, though... that would only require clearing
     32 bytes (vs 256) at the cost of slowing down the loop a little.

					-Matt
					Matthew Dillon 
					<dillon at backplane.com>


More information about the freebsd-current mailing list