Boost performance of QChar::is{Upper,Lower}
Calling QChar::category() is slow; do some fast checks to detect ascii characters before falling back to the generic handling. On ia32, this change makes isUpper ~260x faster for uppercase ascii characters, and ~180x faster for non-uppercase ascii characters. Similar numbers for isLower. Even with the additional checks, these versions are slightly faster than before for non-ascii characters as well, since we now call the static fastcall category(ushort) function, which is faster than the category() member function (which uses the stack to pass the unicode value). Change-Id: I6ae0df466bb4835ca0d5319fd6018862c849313b Reviewed-on: http://codereview.qt-project.org/4901 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
parent
6e55715581
commit
4cd9d267e7
@ -239,8 +239,14 @@ public:
|
||||
bool isLetterOrNumber() const;
|
||||
bool isDigit() const;
|
||||
bool isSymbol() const;
|
||||
inline bool isLower() const { return category() == Letter_Lowercase; }
|
||||
inline bool isUpper() const { return category() == Letter_Uppercase; }
|
||||
inline bool isLower() const {
|
||||
return (ucs >= 'a' && ucs <= 'z')
|
||||
|| (ucs > 127 && category(ucs) == Letter_Lowercase);
|
||||
}
|
||||
inline bool isUpper() const {
|
||||
return (ucs <= 'Z' && ucs >= 'A')
|
||||
|| (ucs > 127 && category(ucs) == Letter_Uppercase);
|
||||
}
|
||||
inline bool isTitleCase() const { return category() == Letter_Titlecase; }
|
||||
|
||||
inline bool isHighSurrogate() const {
|
||||
|
Loading…
Reference in New Issue
Block a user