Chromium Code Reviews

Side by Side Diff: fusl/src/string/strlen.c

Issue 1714623002: [fusl] clang-format fusl (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: headers too Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 #include <string.h> 1 #include <string.h>
2 #include <stdint.h> 2 #include <stdint.h>
3 #include <limits.h> 3 #include <limits.h>
4 4
5 #define ALIGN (sizeof(size_t)) 5 #define ALIGN (sizeof(size_t))
6 #define ONES ((size_t)-1/UCHAR_MAX) 6 #define ONES ((size_t)-1 / UCHAR_MAX)
7 #define HIGHS (ONES * (UCHAR_MAX/2+1)) 7 #define HIGHS (ONES * (UCHAR_MAX / 2 + 1))
8 #define HASZERO(x) ((x)-ONES & ~(x) & HIGHS) 8 #define HASZERO(x) ((x)-ONES & ~(x)&HIGHS)
9 9
10 size_t strlen(const char *s) 10 size_t strlen(const char* s) {
11 { 11 const char* a = s;
12 » const char *a = s; 12 const size_t* w;
13 » const size_t *w; 13 for (; (uintptr_t)s % ALIGN; s++)
14 » for (; (uintptr_t)s % ALIGN; s++) if (!*s) return s-a; 14 if (!*s)
15 » for (w = (const void *)s; !HASZERO(*w); w++); 15 return s - a;
16 » for (s = (const void *)w; *s; s++); 16 for (w = (const void*)s; !HASZERO(*w); w++)
17 » return s-a; 17 ;
18 for (s = (const void*)w; *s; s++)
19 ;
20 return s - a;
18 } 21 }
OLDNEW

Powered by Google App Engine