diff options
Diffstat (limited to 'src/plugins/nim')
-rw-r--r-- | src/plugins/nim/project/nimproject.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/plugins/nim/project/nimproject.cpp b/src/plugins/nim/project/nimproject.cpp index b0d7191c42..99fd84afa2 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<FileNode *> fileNodes = Utils::filtered(m_futureWatcher.future().result(), - [&](const FileNode *fn) { + std::vector<std::unique_ptr<FileNode>> fileNodes + = transform<std::vector>(m_futureWatcher.future().result(), + [](FileNode *fn) { return std::unique_ptr<FileNode>(fn); }); + std::remove_if(std::begin(fileNodes), std::end(fileNodes), + [this](const std::unique_ptr<FileNode> &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<QList>(fileNodes, [](const std::unique_ptr<FileNode> &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<NimProjectNode>(*this, projectDirectory()); newRoot->setDisplayName(displayName()); - newRoot->addNestedNodes(fileNodes); + newRoot->addNestedNodes(std::move(fileNodes)); setRootProjectNode(std::move(newRoot)); emitParsingFinished(true); } |