summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-08-18 17:14:21 (GMT)
committerOswald Buddenhagen <oswald.buddenhagen@nokia.com>2009-09-23 13:44:26 (GMT)
commit5bd5154ae0095a3e166e8be9347c613b2194e0be (patch)
treebd84f2e21f8bc7726c1de90c399716e213c6af02 /tools
parent5fc344431354c00340d9727f64dbb3c29972f93d (diff)
downloadQt-5bd5154ae0095a3e166e8be9347c613b2194e0be.zip
Qt-5bd5154ae0095a3e166e8be9347c613b2194e0be.tar.gz
Qt-5bd5154ae0095a3e166e8be9347c613b2194e0be.tar.bz2
cut down use of qstring::simplified()
Diffstat (limited to 'tools')
-rw-r--r--tools/linguist/lupdate/cpp.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/tools/linguist/lupdate/cpp.cpp b/tools/linguist/lupdate/cpp.cpp
index 9b7fdc8..e72f1c9 100644
--- a/tools/linguist/lupdate/cpp.cpp
+++ b/tools/linguist/lupdate/cpp.cpp
@@ -56,7 +56,7 @@ QT_BEGIN_NAMESPACE
/* qmake ignore Q_OBJECT */
-static const char MagicComment[] = "TRANSLATOR ";
+static QString MagicComment(QLatin1String("TRANSLATOR"));
#define STRING(s) static QString str##s(QLatin1String(#s))
@@ -1811,9 +1811,15 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
}
sourcetext.resize(ptr - (ushort *)sourcetext.data());
} else {
- comment = yyWord.simplified();
- if (comment.startsWith(QLatin1String(MagicComment))) {
- comment.remove(0, sizeof(MagicComment) - 1);
+ const ushort *uc = (const ushort *)yyWord.unicode(); // Is zero-terminated
+ int idx = 0;
+ ushort c;
+ while ((c = uc[idx]) == ' ' || c == '\t' || c == '\n')
+ ++idx;
+ if (!memcmp(uc + idx, MagicComment.unicode(), MagicComment.length() * 2)) {
+ idx += MagicComment.length();
+ comment = QString::fromRawData(yyWord.unicode() + idx,
+ yyWord.length() - idx).simplified();
int k = comment.indexOf(QLatin1Char(' '));
if (k == -1) {
context = comment;
@@ -1826,8 +1832,6 @@ void CppParser::parseInternal(ConversionData &cd, QSet<QString> &inclusions)
results->tor->setExtras(extra);
extra.clear();
}
- } else {
- comment.detach();
}
}
yyTok = getToken();