forked from qt-creator/qt-creator
Don't call non-const methods on temporary QList
Otherwise it may unnecessarily detach. Either store a local const reference or call const equivalent (e.g. constFirst()). Change-Id: I96d665487cf28c17e72bea17f1b8f164ce06cc70 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -3180,17 +3180,14 @@ void EditorManager::openEditorAtSearchResult(const SearchResultItem &item,
|
||||
OpenEditorFlags flags,
|
||||
bool *newEditor)
|
||||
{
|
||||
if (item.path().empty()) {
|
||||
const QStringList &path = item.path();
|
||||
if (path.isEmpty()) {
|
||||
openEditor(FilePath::fromUserInput(item.lineText()), editorId, flags, newEditor);
|
||||
return;
|
||||
}
|
||||
|
||||
openEditorAt({FilePath::fromUserInput(item.path().first()),
|
||||
item.mainRange().begin.line,
|
||||
item.mainRange().begin.column},
|
||||
editorId,
|
||||
flags,
|
||||
newEditor);
|
||||
const Search::TextPosition position = item.mainRange().begin;
|
||||
openEditorAt({FilePath::fromUserInput(path.first()), position.line, position.column},
|
||||
editorId, flags, newEditor);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@@ -281,13 +281,14 @@ QFuture<FileSearchResultList> GitGrep::executeSearch(const TextEditor::FileFindP
|
||||
IEditor *GitGrep::openEditor(const SearchResultItem &item,
|
||||
const TextEditor::FileFindParameters ¶meters)
|
||||
{
|
||||
GitGrepParameters params = parameters.searchEngineParameters.value<GitGrepParameters>();
|
||||
if (params.ref.isEmpty() || item.path().isEmpty())
|
||||
const GitGrepParameters params = parameters.searchEngineParameters.value<GitGrepParameters>();
|
||||
const QStringList &itemPath = item.path();
|
||||
if (params.ref.isEmpty() || itemPath.isEmpty())
|
||||
return nullptr;
|
||||
const QString path = QDir::fromNativeSeparators(item.path().first());
|
||||
const QString path = QDir::fromNativeSeparators(itemPath.first());
|
||||
const FilePath topLevel = FilePath::fromString(parameters.additionalParameters.toString());
|
||||
IEditor *editor = m_client->openShowEditor(
|
||||
topLevel, params.ref, path, GitClient::ShowEditor::OnlyIfDifferent);
|
||||
IEditor *editor = m_client->openShowEditor(topLevel, params.ref, path,
|
||||
GitClient::ShowEditor::OnlyIfDifferent);
|
||||
if (editor)
|
||||
editor->gotoLine(item.mainRange().begin.line, item.mainRange().begin.column);
|
||||
return editor;
|
||||
|
@@ -268,7 +268,7 @@ void PyLSClient::updateExtraCompilerContents(ExtraCompiler *compiler, const File
|
||||
|
||||
void PyLSClient::closeExtraCompiler(ProjectExplorer::ExtraCompiler *compiler)
|
||||
{
|
||||
const FilePath file = compiler->targets().first();
|
||||
const FilePath file = compiler->targets().constFirst();
|
||||
m_extraCompilerOutputDir.pathAppended(file.fileName()).removeFile();
|
||||
compiler->disconnect(this);
|
||||
}
|
||||
|
@@ -484,7 +484,7 @@ FilePaths BaseFileFind::replaceAll(const QString &text,
|
||||
|
||||
QHash<FilePath, QList<SearchResultItem> > changes;
|
||||
for (const SearchResultItem &item : items)
|
||||
changes[FilePath::fromUserInput(item.path().first())].append(item);
|
||||
changes[FilePath::fromUserInput(item.path().constFirst())].append(item);
|
||||
|
||||
// Checking for files without write permissions
|
||||
QSet<FilePath> roFiles;
|
||||
|
@@ -102,7 +102,7 @@ QTextCursor SnippetOverlay::nextSelectionCursor(const QTextCursor &cursor) const
|
||||
if (selections[selectionIndex].m_cursor_begin.position() > cursor.position())
|
||||
return cursorForIndex(selectionIndex);
|
||||
}
|
||||
return cursorForIndex(m_variables[nextVariableIndex].first());
|
||||
return cursorForIndex(m_variables[nextVariableIndex].constFirst());
|
||||
}
|
||||
// currently not over a variable simply select the next available one
|
||||
for (const OverlaySelection &candidate : selections) {
|
||||
@@ -128,7 +128,7 @@ QTextCursor SnippetOverlay::previousSelectionCursor(const QTextCursor &cursor) c
|
||||
if (selections.at(equivalents.at(i)).m_cursor_end.position() < cursor.position())
|
||||
return cursorForIndex(equivalents.at(i));
|
||||
}
|
||||
return cursorForIndex(m_variables[previousVariableIndex].last());
|
||||
return cursorForIndex(m_variables[previousVariableIndex].constLast());
|
||||
}
|
||||
// currently not over a variable simply select the previous available one
|
||||
for (int i = selections.size() - 1; i >= 0; --i) {
|
||||
|
Reference in New Issue
Block a user