Skip to content

Commit 3537b72

Browse files
author
Sriya Pratipati
committed
Changed structure for clarity
1 parent e516ec9 commit 3537b72

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

libc/src/wchar/wcsspn.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
namespace LIBC_NAMESPACE_DECL {
1717

18+
bool check(wchar_t c, const wchar_t *s2) {
19+
for (int n = 0; s2[n]; ++n) {
20+
if (s2[n] == c)
21+
return true;
22+
}
23+
return false;
24+
}
1825
LLVM_LIBC_FUNCTION(size_t, wcsspn, (const wchar_t *s1, const wchar_t *s2)) {
1926
size_t i = 0;
20-
int in_s2 = 0;
2127
for (; s1[i]; ++i) {
22-
for (int n = 0; s2[n] && in_s2 == 0; ++n) {
23-
if (s1[i] == s2[n])
24-
in_s2 = 1;
25-
}
26-
if (in_s2 == 0) {
28+
if (!check(s1[i], s2))
2729
return i;
28-
}
29-
in_s2 = 0;
3030
}
3131
return i;
3232
}

0 commit comments

Comments
 (0)