diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-02-16 07:00:05 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-02-18 18:50:49 +0100 |
commit | 5f338040f4ecbf6404ea5610ec19adfd9ca71c35 (patch) | |
tree | 9fa530dc415514e725d02592c39c3ceb30c5aae7 /src/corelib/tools | |
parent | 795c94658d88d1139d922173aa26beace4ae9fae (diff) |
QColor: avoid Unicode table lookups in fromString()
All color names supported by QColor are US-ASCII.
Enforce this with a static_assert, then use this fact to perform the
case-folding of the input in US-ASCII instead of Unicode.
Avoids lookups in the Unicode tables.
Add QtMiscUtils::toAsciiLower() to foster sharing.
Change-Id: Ie0e123405d772943313dc4be1808667b152770b1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/tools')
-rw-r--r-- | src/corelib/tools/qtools_p.h | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/tools/qtools_p.h b/src/corelib/tools/qtools_p.h index 8854ae8c48..9d4a3ffe60 100644 --- a/src/corelib/tools/qtools_p.h +++ b/src/corelib/tools/qtools_p.h @@ -84,6 +84,11 @@ constexpr inline int fromOct(uint c) noexcept { return ((c >= '0') && (c <= '7')) ? int(c - '0') : -1; } + +constexpr inline char toAsciiLower(char ch) noexcept +{ + return (ch >= 'A' && ch <= 'Z') ? ch - 'A' + 'a' : ch; +} } // We typically need an extra bit for qNextPowerOfTwo when determining the next allocation size. |