diff options
author | Julian Andres Klode <jak@debian.org> | 2015-12-29 03:19:51 +0100 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2015-12-29 03:19:51 +0100 |
commit | 98eb4e9eec4e2e1fc62fe018d536b89f5524cd21 (patch) | |
tree | f65268d06ad96aa08a90a321475600c59a6bead3 /apt-pkg/contrib/strutl.cc | |
parent | 0748f03aca4db260ad964b44519e0971647d1e9d (diff) |
Turn tolower_ascii() and isspace_ascii() into inline functions
To preserve compatibility, the new inline functions have _inline
as a suffix, and a macro defines the old names to refer to the
inline variants.
The old functions are still preserved for binary compatibility.
Also simplify the implementation of both functions.
Diffstat (limited to 'apt-pkg/contrib/strutl.cc')
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index 457bd73a2..60e3156f1 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1369,17 +1369,17 @@ string StripEpoch(const string &VerStr) return VerStr.substr(i+1); } /*}}}*/ + // tolower_ascii - tolower() function that ignores the locale /*{{{*/ // --------------------------------------------------------------------- /* This little function is the most called method we have and tries therefore to do the absolut minimum - and is notable faster than standard tolower/toupper and as a bonus avoids problems with different locales - we only operate on ascii chars anyway. */ +#undef tolower_ascii int tolower_ascii(int const c) { - if (c >= 'A' && c <= 'Z') - return c + 32; - return c; + return tolower_ascii_inline(c); } /*}}}*/ @@ -1389,14 +1389,10 @@ int tolower_ascii(int const c) therefore to do the absolut minimum - and is notable faster than standard isspace() and as a bonus avoids problems with different locales - we only operate on ascii chars anyway. */ +#undef isspace_ascii int isspace_ascii(int const c) { - return (c == ' ' - || c == '\f' - || c == '\n' - || c == '\r' - || c == '\t' - || c == '\v'); + return isspace_ascii_inline(c); } /*}}}*/ |