Skip to content

Commit 06f6a77

Browse files
[libc] Simplify wcscmp (#143457)
The implementation of wcscmp mimicked strcmp, but was more complicated than necessary. This patch makes it simpler.
1 parent bdcfcf6 commit 06f6a77

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

libc/src/wchar/wcscmp.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ LLVM_LIBC_FUNCTION(int, wcscmp, (const wchar_t *left, const wchar_t *right)) {
1919
LIBC_CRASH_ON_NULLPTR(left);
2020
LIBC_CRASH_ON_NULLPTR(right);
2121

22-
auto comp = [](wchar_t l, wchar_t r) -> int { return l - r; };
23-
24-
for (; *left && !comp(*left, *right); ++left, ++right)
22+
for (; *left && (*left == *right); ++left, ++right)
2523
;
2624

27-
return comp(*left, *right);
25+
return *left - *right;
2826
}
2927

3028
} // namespace LIBC_NAMESPACE_DECL

0 commit comments

Comments
 (0)