mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-21 09:14:03 +08:00
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:
parent
71a0d839a7
commit
1ab81ab90d
|
@ -55,7 +55,7 @@ int wcsfilecmp(const wchar_t *a, const wchar_t *b) {
|
||||||
int retval = 0; // assume the strings will be equal
|
int retval = 0; // assume the strings will be equal
|
||||||
|
|
||||||
while (*a && *b) {
|
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);
|
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
|
// 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.
|
// 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
|
int retval = 0; // assume the strings will be equal
|
||||||
|
|
||||||
while (*a && *b) {
|
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);
|
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
|
// 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.
|
// strings we can stop iterating over the chars in each string.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user