Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Use QString/QByteArray::remove() over assigning a mid() snippet to self

parent 03d24355
......@@ -500,7 +500,7 @@ static QStringList splitAndKeep(QString str, const QRegExp& regExp) {
int place = regExp.indexIn(str);
while(place != -1) {
ret << str.left(place + regExp.matchedLength());
str = str.mid(place + regExp.matchedLength());
str.remove(0, place + regExp.matchedLength());
place = regExp.indexIn(str);
}
ret << str;
......
......@@ -96,8 +96,8 @@ QString highlightAndEscapeUseText(QString line, int cutOff, KTextEditor::Range r
}
Q_ASSERT(leftCut + rightCut <= cutOff);
line = line.left(line.length() - rightCut);
line = line.mid(leftCut);
line.chop(rightCut);
line.remove(0, leftCut);
range += KTextEditor::Range(0, -leftCut, 0, -leftCut);
Q_ASSERT(range.start().column() >= 0 && range.end().column() <= line.length());
......
......@@ -1130,7 +1130,7 @@ QString ProjectController::prettyFilePath(const QUrl& url, FormattingOptions for
}
QString relativePath = project->path().relativePath(parent);
if(relativePath.startsWith(QLatin1String("./"))) {
relativePath = relativePath.mid(2);
relativePath.remove(0, 2);
}
if (!relativePath.isEmpty()) {
prefixText += relativePath + QLatin1Char('/');
......
......@@ -409,7 +409,7 @@ QString SourceFormatterController::addModelineForCurrentLang(QString input, cons
for (QString s : optionList) {
if (knownOptions.indexIn(s) < 0) { // unknown option, add it
if(s.startsWith(QLatin1Char(' ')))
s=s.mid(1);
s.remove(0, 1);
os << s << ";";
qCDebug(SHELL) << "Found unknown option: " << s << endl;
}
......
......@@ -352,7 +352,7 @@ ClangFixit directiveForFile( const QString& includefile, const KDevelop::Path::L
for( const auto& includePath : includepaths ) {
QString relative = includePath.relativePath( canonicalFile );
if( relative.startsWith( QLatin1String("./") ) )
relative = relative.mid( 2 );
relative.remove(0, 2);
if( shortestDirective.isEmpty() || relative.length() < shortestDirective.length() ) {
shortestDirective = relative;
......
......@@ -623,7 +623,7 @@ void TestAssistants::testUnknownDeclarationAssistant()
{
auto fileName = testbed.includeFileName();
fileName = fileName.mid(fileName.lastIndexOf('/') + 1);
fileName.remove(0, fileName.lastIndexOf('/') + 1);
const auto directive = QStringLiteral("#include \"%1\"").arg(fileName);
const auto description = i18n("Insert \'%1\'", directive);
const bool hasMissingInclude = actionDescriptions.contains(description);
......
......@@ -137,7 +137,7 @@ void CMakeServer::processOutput()
const int idx = m_buffer.indexOf(closeTag, openTag.size());
if (idx >= 0) {
emitResponse(m_buffer.mid(openTag.size(), idx - openTag.size()));
m_buffer = m_buffer.mid(idx + closeTag.size());
m_buffer.remove(0, idx + closeTag.size());
} else {
break;
}
......
......@@ -1338,7 +1338,7 @@ void ContextBrowserPlugin::updateHistory(KDevelop::DUContext* context, const KTe
updateButtonState();
if(m_history.size() > (maxHistoryLength + 5)) {
m_history = m_history.mid(m_history.size() - maxHistoryLength);
m_history.remove(0, m_history.size() - maxHistoryLength);
m_nextHistoryIndex = m_history.size();
}
}
......
......@@ -249,7 +249,7 @@ PathResolutionResult MakeFileResolver::resolveIncludePath(const QString& file, c
if (workingDirectory == QLatin1String("."))
workingDirectory = QString();
else if (workingDirectory.startsWith(QLatin1String("./")))
workingDirectory = workingDirectory.mid(2);
workingDirectory.remove(0, 2);
if (!workingDirectory.isEmpty()) {
u = u.adjusted(QUrl::StripTrailingSlash);
......
......@@ -139,7 +139,7 @@ void MIDebugger::readyReadStandardOutput()
if (i == -1)
break;
QByteArray reply(m_buffer.left(i));
m_buffer = m_buffer.mid(i+1);
m_buffer.remove(0, i+1);
processLine(reply);
}
......
......@@ -171,10 +171,10 @@ QString LldbCommand::cmdToSend()
QString env_name = QStringLiteral("environment ");
QString disassembly_flavor = QStringLiteral("disassembly-flavor ");
if (command_.startsWith(env_name)) {
command_ = command_.mid(env_name.length());
command_.remove(0, env_name.length());
overrideCmd = QStringLiteral("settings set target.env-vars");
} else if (command_.startsWith(disassembly_flavor)) {
command_ = command_.mid(disassembly_flavor.length());
command_.remove(0, disassembly_flavor.length());
overrideCmd = QStringLiteral("settings set target.x86-disassembly-flavor");
}
break;
......
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