diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2014-06-19 10:56:50 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2014-07-07 07:12:10 +0200 |
commit | 7e488626ab484ef8f62be6f80791a0b3adae80ab (patch) | |
tree | be99a82d7ed402825d38cca79dfb9b291e0e4a16 /src/corelib/tools/qstring.cpp | |
parent | 9f0e5d00ab51cc7c0dc87c8d72f48c4e6edaf120 (diff) |
Don't look up a QChar's digit value more than necessary
It isn't a particularly complex operation, but why waste CPU cycles?
This is the kind of function that should be declared pure/const.
Change-Id: I13f03ef0f87607f7649c66beeb37614a31ef2a10
Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
Diffstat (limited to 'src/corelib/tools/qstring.cpp')
-rw-r--r-- | src/corelib/tools/qstring.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 7aaddb9b52..ca6367b113 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -6960,15 +6960,18 @@ static ArgEscapeData findArgEscapes(const QString &s) break; } - if (c->digitValue() == -1) + int escape = c->digitValue(); + if (escape == -1) continue; - int escape = c->digitValue(); ++c; - if (c != uc_end && c->digitValue() != -1) { - escape = (10 * escape) + c->digitValue(); - ++c; + if (c != uc_end) { + int next_escape = c->digitValue(); + if (next_escape != -1) { + escape = (10 * escape) + next_escape; + ++c; + } } if (escape > d.min_escape) |