From 7e488626ab484ef8f62be6f80791a0b3adae80ab Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 19 Jun 2014 10:56:50 -0700 Subject: 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 Reviewed-by: Robin Burchell --- src/corelib/tools/qstring.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/corelib') 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) -- cgit v1.2.3