mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
Shadow/override iswdigit instead of changing it at individual call sites
1ab81ab90d
removed one usage of iswdigit()
but there are others; more importantly, the knowledge that iswdigit() is
slow isn't preserved anywhere apart from the git history, so there's
nothing to prevent its use from creeping back into the codebase.
Another alternative is to blacklist iswdigit() (shadow it with a
function of the same name that throws a static_assert) but if we're
going to shadow it anyway, might as well make it useful.
This commit is contained in:
parent
72e50d1ab2
commit
fe63c8ad32
1 changed files with 8 additions and 0 deletions
|
@ -699,4 +699,12 @@ const T *get_by_sorted_name(const wcstring &name, const T (&vals)[N]) {
|
|||
return get_by_sorted_name(name.c_str(), vals);
|
||||
}
|
||||
|
||||
/// As established in 1ab81ab90d1a408702e11f081fdaaafa30636c31, iswdigit() is very slow under glibc,
|
||||
/// and does nothing more than establish whether or not the single specified character is in the
|
||||
/// range ('0','9').
|
||||
__attribute__((always_inline))
|
||||
bool inline iswdigit(const wchar_t c) {
|
||||
return c >= L'0' && c <= L'9';
|
||||
}
|
||||
|
||||
#endif // FISH_COMMON_H
|
||||
|
|
Loading…
Reference in a new issue