Use size() of given QLatin1String instead of strlen on duplicated string

GIT_SILENT
parent 7b6ea635
......@@ -246,8 +246,9 @@ QString ProblemNavigationContext::html(bool shorten)
NavigationContextPointer ProblemNavigationContext::executeKeyAction(const QString& key)
{
if (key.startsWith(QLatin1String("invoke_action_"))) {
const int index = key.midRef(strlen("invoke_action_")).toInt();
const QLatin1String invokeActionPrefix("invoke_action_");
if (key.startsWith(invokeActionPrefix)) {
const int index = key.midRef(invokeActionPrefix.size()).toInt();
executeAction(index);
}
......
......@@ -202,12 +202,14 @@ QStringList QMakeProjectFile::includeDirectories() const
QString pattern = module;
bool isPrivate = false;
if (module.endsWith(QLatin1String("-private"))) {
pattern.chop(qstrlen("-private"));
const QLatin1String dashPrivateLineEnd("-private");
const QLatin1String underscorePrivateLineEnd("_private");
if (module.endsWith(dashPrivateLineEnd)) {
pattern.chop(dashPrivateLineEnd.size());
isPrivate = true;
} else if (module.endsWith(QLatin1String("_private"))) {
} else if (module.endsWith(underscorePrivateLineEnd)) {
// _private is less common, but still a valid suffix
pattern.chop(qstrlen("_private"));
pattern.chop(underscorePrivateLineEnd.size());
isPrivate = true;
}
......
......@@ -46,8 +46,9 @@ QString repairDiff(const QString& diff) {
QStringList lines = diff.split(QLatin1Char('\n'));
QMap<QString, QString> headers;
for(int a = 0; a < lines.size()-1; ++a) {
if(lines[a].startsWith(QLatin1String("Index: ")) && lines[a+1].startsWith(QLatin1String("====="))) {
const QString fileName = lines[a].midRef(strlen("Index: ")).trimmed().toString();
const QLatin1String indexLineBegin("Index: ");
if(lines[a].startsWith(indexLineBegin) && lines[a+1].startsWith(QLatin1String("====="))) {
const QString fileName = lines[a].midRef(indexLineBegin.size()).trimmed().toString();
headers[fileName] = lines[a];
qCDebug(PLUGIN_SVN) << "found header for" << fileName;
lines[a] = QString();
......@@ -61,8 +62,9 @@ QString repairDiff(const QString& diff) {
QRegExp spaceRegExp(QStringLiteral("\\s"));
for(int a = 0; a < lines.size()-1; ++a) {
if(lines[a].startsWith(QLatin1String("--- "))) {
QString tail = lines[a].mid(strlen("--- "));
const QLatin1String threeDashLineBegin("--- ");
if(lines[a].startsWith(threeDashLineBegin)) {
QString tail = lines[a].mid(threeDashLineBegin.size());
if(tail.indexOf(spaceRegExp) != -1) {
QString file = tail.left(tail.indexOf(spaceRegExp));
qCDebug(PLUGIN_SVN) << "checking for" << file;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment