summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.h
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-09-14 13:38:39 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-15 20:39:28 +0200
commita48e9af146ee1d7571934994065e7164fd323f18 (patch)
treeeae84b3faf30a4c0c7489ec2b6c6c0da1f4630fa /src/corelib/tools/qchar.h
parent5639423ea7322d5880d68c61c480a3a084ac4f8b (diff)
Boost performance of QChar::isLetter
Make it inline; add fast checks for ascii letters; add fallback function that uses the fastcall calling convention. On ia32, this change makes isLetter ~370x faster for ascii letters, ~250x faster for non-letter ascii characters, and ~1.5x faster for non-ascii characters. Note that this change is NOT binary compatible. Also add an autotest with expected results from before the optimization, to ensure that the behavior is the same. Change-Id: I06f8d3d43114537cee5567e670898cef6494c20a Reviewed-on: http://codereview.qt-project.org/4903 Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com> Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qchar.h')
-rw-r--r--src/corelib/tools/qchar.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/tools/qchar.h b/src/corelib/tools/qchar.h
index 801cb7d699..fc5a9b051d 100644
--- a/src/corelib/tools/qchar.h
+++ b/src/corelib/tools/qchar.h
@@ -234,7 +234,11 @@ public:
bool isPunct() const;
bool isSpace() const;
bool isMark() const;
- bool isLetter() const;
+ inline bool isLetter() const {
+ return (ucs >= 'a' && ucs <= 'z')
+ || (ucs <= 'Z' && ucs >= 'A')
+ || (ucs > 127 && isLetter(ucs));
+ }
bool isNumber() const;
bool isLetterOrNumber() const;
inline bool isDigit() const
@@ -317,6 +321,7 @@ public:
private:
static bool QT_FASTCALL isDigit(ushort ucs2);
+ static bool QT_FASTCALL isLetter(ushort ucs2);
#ifdef QT_NO_CAST_FROM_ASCII
QChar(char c);