Skip to content

Commit

Permalink
use strpbrk instead of textbook inefficient roll your own version
Browse files Browse the repository at this point in the history
Most libc strpbrk'es are written in assembly and/or use CS voodoo with
lookup arrays to eliminate the inner loop. Dmake's version does neither.
searchchars is usually DirBrkStr from Filedir() and Basename().
This one commit cut the execution time of CacheStat with a cache hit, in
half according to my profiler.
  • Loading branch information
bulk88 authored and mohawk2 committed Mar 9, 2015
1 parent 9da2d00 commit 1bd61f0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion dmstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ char *searchchars;

if( s1 == NIL(char) || searchchars == NIL(char) ) return( "" );

for( t=s1; *t && (strchr( searchchars, *t ) == NIL(char)); t++ );
t = strpbrk(s1, searchchars);
if( !t )
t = s1+strlen(s1);
return( t );
}

Expand Down

0 comments on commit 1bd61f0

Please sign in to comment.