indexer: minor tweaking
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** Copyright (C) 2020-2023 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
** Copyright (C) 2020-2025 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
|
||||||
**
|
**
|
||||||
** This program is free software; you can redistribute it and/or modify it
|
** 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
|
** under the terms of the GNU General Public License as published by the
|
||||||
@ -22,12 +22,9 @@
|
|||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <algorithm>
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <condition_variable>
|
|
||||||
#include <iostream>
|
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
@ -286,11 +283,11 @@ Indexer::Private::cleanup()
|
|||||||
using DirFiles = std::unordered_set<std::string>;
|
using DirFiles = std::unordered_set<std::string>;
|
||||||
std::unordered_map<std::string, DirFiles> dir_cache;
|
std::unordered_map<std::string, DirFiles> 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;
|
DirFiles ret;
|
||||||
auto dir{::opendir(path.c_str())};
|
if (auto dir{::opendir(path.c_str())}; dir) {
|
||||||
if (dir) {
|
dirent* dentry{};
|
||||||
struct dirent* dentry;
|
|
||||||
while ((dentry = ::readdir(dir))) {
|
while ((dentry = ::readdir(dir))) {
|
||||||
ret.emplace(dentry->d_name);
|
ret.emplace(dentry->d_name);
|
||||||
}
|
}
|
||||||
@ -300,7 +297,8 @@ Indexer::Private::cleanup()
|
|||||||
return ret;
|
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);
|
std::string dir = dirname(path);
|
||||||
auto [it, inserted] = dir_cache.try_emplace(dir);
|
auto [it, inserted] = dir_cache.try_emplace(dir);
|
||||||
DirFiles& dir_files = it->second;
|
DirFiles& dir_files = it->second;
|
||||||
|
|||||||
Reference in New Issue
Block a user