summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools/qchar.cpp
diff options
context:
space:
mode:
authorKent Hansen <kent.hansen@nokia.com>2011-09-14 12:53:20 +0200
committerQt by Nokia <qt-info@nokia.com>2011-09-15 20:39:28 +0200
commit5639423ea7322d5880d68c61c480a3a084ac4f8b (patch)
tree8b07bbb6e7ed6ad1972e6a0f816cfcb9a0819fd7 /src/corelib/tools/qchar.cpp
parent4cd9d267e727b0b146f0f2d5b41cf62c97145fb4 (diff)
Boost performance of QChar::isDigit
Make it inline; add fast checks for ascii digits; add fallback function that uses the fastcall calling convention. On ia32, this change makes isDigit ~370x faster for ascii digit characters, ~250x faster for non-digit 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: I718fadecda3f591d6f4c22374d8e476f4724fd83 Reviewed-on: http://codereview.qt-project.org/4902 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.cpp')
-rw-r--r--src/corelib/tools/qchar.cpp11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/corelib/tools/qchar.cpp b/src/corelib/tools/qchar.cpp
index b68da9def4..5d4769d7f0 100644
--- a/src/corelib/tools/qchar.cpp
+++ b/src/corelib/tools/qchar.cpp
@@ -601,12 +601,19 @@ bool QChar::isLetterOrNumber() const
}
/*!
+ \fn bool QChar::isDigit() const
+
Returns true if the character is a decimal digit
(Number_DecimalDigit); otherwise returns false.
*/
-bool QChar::isDigit() const
+
+/*!
+ \internal
+ \overload
+*/
+bool QChar::isDigit(ushort ucs2)
{
- return (qGetProp(ucs)->category == Number_DecimalDigit);
+ return (qGetProp(ucs2)->category == Number_DecimalDigit);
}
/*!