Cache result of QDir::separator() outside of loops

parent 82b3cb40
......@@ -111,8 +111,9 @@ bool KDevFormatFile::apply()
return executeCommand(formatLine.command);
}
const QChar dirSeparator = QDir::separator();
for (const QString& wildcard : formatLine.wildcards) {
if (QDir::match(QDir::current().canonicalPath() + QDir::separator() + wildcard.trimmed(), m_origFilePath)) {
if (QDir::match(QDir::current().canonicalPath() + dirSeparator + wildcard.trimmed(), m_origFilePath)) {
qStdOut() << "matched \"" << m_origFilePath << "\" with wildcard \"" << wildcard << '\"';
return executeCommand(formatLine.command);
}
......
......@@ -148,8 +148,9 @@ bool BazaarPlugin::isVersionControlled(const QUrl& localLocation)
QList<QFileInfo> filesAndDirectoriesList;
const auto output = job->output().split(QLatin1Char('\n'));
filesAndDirectoriesList.reserve(output.size());
const QChar dirSeparator = QDir::separator();
for (const auto& fod : output) {
filesAndDirectoriesList.append(QFileInfo(workCopy.absolutePath() + QDir::separator() + fod));
filesAndDirectoriesList.append(QFileInfo(workCopy.absolutePath() + dirSeparator + fod));
}
QFileInfo fi(localLocation.toLocalFile());
if (fi.isDir() || fi.isFile()) {
......
......@@ -141,8 +141,9 @@ QStringList scanIncludePaths( const QualifiedIdentifier& identifier, const KDeve
int sharedPathLevel(const QString& a, const QString& b)
{
int shared = -1;
const QChar dirSeparator = QDir::separator();
for (auto x = a.begin(), y = b.begin(); x != a.end() && y != b.end() && *x == *y; ++x, ++y) {
if( *x == QDir::separator() ) {
if (*x == dirSeparator) {
++shared;
}
}
......
......@@ -88,6 +88,7 @@ std::pair<Path::List, QHash<QString, QString>>
if (f.open(QIODevice::ReadOnly | QIODevice::Text)) {
auto lines = QString::fromLocal8Bit(f.readAll()).split(QLatin1Char('\n'), QString::SkipEmptyParts);
QFileInfo dir(pathToFile);
const QChar dirSeparator = QDir::separator();
for (const auto& line : lines) {
auto textLine = line.trimmed();
if (textLine.startsWith(QLatin1String("#define "))) {
......@@ -103,7 +104,7 @@ std::pair<Path::List, QHash<QString, QString>>
if (!textLine.isEmpty()) {
QFileInfo pathInfo(textLine);
if (pathInfo.isRelative()) {
includes << Path(dir.canonicalPath() + QDir::separator() + textLine);
includes << Path(dir.canonicalPath() + dirSeparator + textLine);
} else {
includes << Path(textLine);
}
......
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