mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-26 10:43:47 +08:00
wcsfilecmp: Skip towlower/upper if unnecessary
Also for the glob version, because this is just a performance thing. Makes `echo **` 20% faster - 100ms to 80ms for the fish repo. This also applies to the future `path` builtin. Still not a speed demon, but this is a very very easy win. Now we probably gotta do globbing all in string instead of wcs2stringing ourselves to death.
This commit is contained in:
parent
4ffabd44be
commit
78fcbed6f2
14
src/util.cpp
14
src/util.cpp
|
@ -62,6 +62,13 @@ int wcsfilecmp(const wchar_t *a, const wchar_t *b) {
|
|||
if (retval || *a == 0 || *b == 0) break;
|
||||
}
|
||||
|
||||
// Fast path: Skip towupper.
|
||||
if (*a == *b) {
|
||||
a++;
|
||||
b++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wint_t al = towupper(*a);
|
||||
wint_t bl = towupper(*b);
|
||||
// Sort dashes after Z - see #5634
|
||||
|
@ -115,6 +122,13 @@ int wcsfilecmp_glob(const wchar_t *a, const wchar_t *b) {
|
|||
if (retval || *a == 0 || *b == 0) break;
|
||||
}
|
||||
|
||||
// Fast path: Skip towlower.
|
||||
if (*a == *b) {
|
||||
a++;
|
||||
b++;
|
||||
continue;
|
||||
}
|
||||
|
||||
wint_t al = towlower(*a);
|
||||
wint_t bl = towlower(*b);
|
||||
if (al < bl) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user