wcsfilecmp: Don't use iswdigit

For some godforsaken reason it's slow on glibc

Like, actually, this manages to somehow make "echo **" 10% faster now?

The spec says this matches 0 through 9 always, so this is safe. We
also use this logic in a variety of other places already.
This commit is contained in:
Fabian Homborg 2021-10-01 15:43:58 +02:00
parent 71a0d839a7
commit 1ab81ab90d

View file

@ -55,7 +55,7 @@ int wcsfilecmp(const wchar_t *a, const wchar_t *b) {
int retval = 0; // assume the strings will be equal
while (*a && *b) {
if (iswdigit(*a) && iswdigit(*b)) {
if (*a >= L'0' && *a <= L'9' && *b >= L'0' && *b <= L'9') {
retval = wcsfilecmp_leading_digits(&a, &b);
// If we know the strings aren't logically equal or we've reached the end of one or both
// strings we can stop iterating over the chars in each string.
@ -115,7 +115,7 @@ int wcsfilecmp_glob(const wchar_t *a, const wchar_t *b) {
int retval = 0; // assume the strings will be equal
while (*a && *b) {
if (iswdigit(*a) && iswdigit(*b)) {
if (*a >= L'0' && *a <= L'9' && *b >= L'0' && *b <= L'9') {
retval = wcsfilecmp_leading_digits(&a, &b);
// If we know the strings aren't logically equal or we've reached the end of one or both
// strings we can stop iterating over the chars in each string.