From 18092c7ff9d3a9f478dc9fb305bdec63254d945a Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sun, 23 Feb 2025 11:36:46 +0200 Subject: [PATCH] indexer: minor tweaking --- lib/mu-indexer.cc | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/mu-indexer.cc b/lib/mu-indexer.cc index 0e1d8e72..482812d9 100644 --- a/lib/mu-indexer.cc +++ b/lib/mu-indexer.cc @@ -1,5 +1,5 @@ /* -** Copyright (C) 2020-2023 Dirk-Jan C. Binnema +** Copyright (C) 2020-2025 Dirk-Jan C. Binnema ** ** This program is free software; you can redistribute it and/or modify it ** under the terms of the GNU General Public License as published by the @@ -22,12 +22,9 @@ #include #include -#include #include #include #include -#include -#include #include #include #include @@ -286,11 +283,11 @@ Indexer::Private::cleanup() using DirFiles = std::unordered_set; std::unordered_map dir_cache; - auto get_dir_files = [](const std::string& path) -> DirFiles { + // get a set of file names in this directory. + const auto get_dir_files = [](const std::string& path) -> DirFiles { DirFiles ret; - auto dir{::opendir(path.c_str())}; - if (dir) { - struct dirent* dentry; + if (auto dir{::opendir(path.c_str())}; dir) { + dirent* dentry{}; while ((dentry = ::readdir(dir))) { ret.emplace(dentry->d_name); } @@ -300,7 +297,8 @@ Indexer::Private::cleanup() return ret; }; - auto is_file_present = [&](const std::string& path) -> bool { + // is the file present in our set? + const auto is_file_present = [&](const std::string& path) -> bool { std::string dir = dirname(path); auto [it, inserted] = dir_cache.try_emplace(dir); DirFiles& dir_files = it->second;