From 522492d85d4ef1db119b4fbfa5d33f9166e7a206 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Thu, 26 Apr 2018 16:48:12 +0200 Subject: [PATCH] NimProject: Use FolderNode::addNestedNodes that takes unique_ptrs Change-Id: Ibd8fb90ae38f2f3ae6e522a78c68632b4b2f0c38 Reviewed-by: Ulf Hermann --- src/plugins/nim/project/nimproject.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp index b0d7191c429..99fd84afa2d 100644 --- a/src/plugins/nim/project/nimproject.cpp +++ b/src/plugins/nim/project/nimproject.cpp @@ -129,19 +129,21 @@ void NimProject::updateProject() const QStringList oldFiles = m_files; m_files.clear(); - QList fileNodes = Utils::filtered(m_futureWatcher.future().result(), - [&](const FileNode *fn) { + std::vector> fileNodes + = transform(m_futureWatcher.future().result(), + [](FileNode *fn) { return std::unique_ptr(fn); }); + std::remove_if(std::begin(fileNodes), std::end(fileNodes), + [this](const std::unique_ptr &fn) { const FileName path = fn->filePath(); const QString fileName = path.fileName(); - const bool keep = !m_excludedFiles.contains(path.toString()) - && !fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity()) - && !fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity()); - if (!keep) - delete fn; - return keep; + return m_excludedFiles.contains(path.toString()) + || fileName.endsWith(".nimproject", HostOsInfo::fileNameCaseSensitivity()) + || fileName.contains(".nimproject.user", HostOsInfo::fileNameCaseSensitivity()); }); - m_files = Utils::transform(fileNodes, [](const FileNode *fn) { return fn->filePath().toString(); }); + m_files = transform(fileNodes, [](const std::unique_ptr &fn) { + return fn->filePath().toString(); + }); Utils::sort(m_files, [](const QString &a, const QString &b) { return a < b; }); if (oldFiles == m_files) @@ -149,7 +151,7 @@ void NimProject::updateProject() auto newRoot = std::make_unique(*this, projectDirectory()); newRoot->setDisplayName(displayName()); - newRoot->addNestedNodes(fileNodes); + newRoot->addNestedNodes(std::move(fileNodes)); setRootProjectNode(std::move(newRoot)); emitParsingFinished(true); }