byte_chr.c (393B)
1 #include "byte.h" 2 3 unsigned int byte_chr(char *s, unsigned int n, int c) 4 { 5 char ch; 6 char *t; 7 8 ch = c; 9 t = s; 10 for (;;) { 11 if (!n) break; if (*t == ch) break; ++t; --n; 12 if (!n) break; if (*t == ch) break; ++t; --n; 13 if (!n) break; if (*t == ch) break; ++t; --n; 14 if (!n) break; if (*t == ch) break; ++t; --n; 15 } 16 /* loop unrolling? smart bernstein. */ 17 return t - s; 18 }