mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-09 20:41:04 -04:00
refactor: small cleanups around variable shadowing and scope
This commit is contained in:
parent
5e6c78da04
commit
f6a9ce1c89
@ -609,7 +609,7 @@ class block_cache_ final : public block_cache::impl {
|
|||||||
|
|
||||||
// Check if another worker is already processing this block
|
// Check if another worker is already processing this block
|
||||||
{
|
{
|
||||||
std::lock_guard lock(mx_dec_);
|
std::lock_guard lock_dec(mx_dec_);
|
||||||
|
|
||||||
auto di = decompressing_.find(block_no);
|
auto di = decompressing_.find(block_no);
|
||||||
|
|
||||||
|
@ -282,8 +282,8 @@ fragment_category categorizer_manager::default_category() {
|
|||||||
|
|
||||||
template <typename LoggerPolicy>
|
template <typename LoggerPolicy>
|
||||||
void categorizer_manager_<LoggerPolicy>::add(std::shared_ptr<categorizer> c) {
|
void categorizer_manager_<LoggerPolicy>::add(std::shared_ptr<categorizer> c) {
|
||||||
for (auto const& c : c->categories()) {
|
for (auto const& cat : c->categories()) {
|
||||||
add_category(c, categorizers_.size());
|
add_category(cat, categorizers_.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
categorizers_.emplace_back(std::move(c));
|
categorizers_.emplace_back(std::move(c));
|
||||||
|
@ -195,9 +195,8 @@ void inode_reader_<LoggerPolicy>::do_readahead(uint32_t inode,
|
|||||||
std::lock_guard lock(readahead_cache_mutex_);
|
std::lock_guard lock(readahead_cache_mutex_);
|
||||||
|
|
||||||
if (read_offset > 0) {
|
if (read_offset > 0) {
|
||||||
if (auto it = readahead_cache_.find(inode);
|
if (auto i = readahead_cache_.find(inode); i != readahead_cache_.end()) {
|
||||||
it != readahead_cache_.end()) {
|
readahead_pos = i->second;
|
||||||
readahead_pos = it->second;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readahead_until <= readahead_pos) {
|
if (readahead_until <= readahead_pos) {
|
||||||
|
@ -491,10 +491,10 @@ scanner_<LoggerPolicy>::scan_tree(std::filesystem::path const& path,
|
|||||||
DWARFS_CHECK(parent, "expected directory");
|
DWARFS_CHECK(parent, "expected directory");
|
||||||
|
|
||||||
queue.pop_front();
|
queue.pop_front();
|
||||||
auto path = parent->fs_path();
|
auto ppath = parent->fs_path();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
auto d = os_->opendir(path);
|
auto d = os_->opendir(ppath);
|
||||||
std::filesystem::path name;
|
std::filesystem::path name;
|
||||||
std::vector<std::shared_ptr<entry>> subdirs;
|
std::vector<std::shared_ptr<entry>> subdirs;
|
||||||
|
|
||||||
@ -510,7 +510,7 @@ scanner_<LoggerPolicy>::scan_tree(std::filesystem::path const& path,
|
|||||||
|
|
||||||
prog.dirs_scanned++;
|
prog.dirs_scanned++;
|
||||||
} catch (const std::system_error& e) {
|
} catch (const std::system_error& e) {
|
||||||
LOG_ERROR << "cannot read directory `" << path
|
LOG_ERROR << "cannot read directory `" << ppath
|
||||||
<< "`: " << folly::exceptionStr(e);
|
<< "`: " << folly::exceptionStr(e);
|
||||||
prog.errors++;
|
prog.errors++;
|
||||||
}
|
}
|
||||||
|
@ -272,9 +272,7 @@ void utf8_sanitize(std::string& str) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void shorten_path_string(std::string& path, char separator, size_t max_len) {
|
void shorten_path_string(std::string& path, char separator, size_t max_len) {
|
||||||
auto len = utf8_display_width(path);
|
if (utf8_display_width(path) > max_len) {
|
||||||
|
|
||||||
if (len > max_len) {
|
|
||||||
if (max_len < 3) {
|
if (max_len < 3) {
|
||||||
path.clear();
|
path.clear();
|
||||||
return;
|
return;
|
||||||
@ -293,7 +291,7 @@ void shorten_path_string(std::string& path, char separator, size_t max_len) {
|
|||||||
|
|
||||||
path.replace(0, start, "...");
|
path.replace(0, start, "...");
|
||||||
|
|
||||||
if (auto len = utf8_display_width(path); len > max_len) {
|
if (utf8_display_width(path) > max_len) {
|
||||||
if (max_len >= 7) {
|
if (max_len >= 7) {
|
||||||
utf8_truncate(path, max_len - 3);
|
utf8_truncate(path, max_len - 3);
|
||||||
path += "...";
|
path += "...";
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include <folly/Conv.h>
|
#include <folly/Conv.h>
|
||||||
#include <folly/FileUtil.h>
|
#include <folly/FileUtil.h>
|
||||||
#include <folly/String.h>
|
#include <folly/String.h>
|
||||||
|
#include <folly/container/Enumerate.h>
|
||||||
#include <folly/gen/String.h>
|
#include <folly/gen/String.h>
|
||||||
#include <folly/portability/SysStat.h>
|
#include <folly/portability/SysStat.h>
|
||||||
#include <folly/system/HardwareConcurrency.h>
|
#include <folly/system/HardwareConcurrency.h>
|
||||||
@ -334,8 +335,8 @@ class categorize_optval {
|
|||||||
void add_implicit_defaults(T& cop) const {
|
void add_implicit_defaults(T& cop) const {
|
||||||
if (is_implicit_default()) {
|
if (is_implicit_default()) {
|
||||||
if (auto it = defaults_.find(cop.name()); it != defaults_.end()) {
|
if (auto it = defaults_.find(cop.name()); it != defaults_.end()) {
|
||||||
for (auto const& value : it->second) {
|
for (auto const& v : it->second) {
|
||||||
cop.parse_fallback(value);
|
cop.parse_fallback(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -713,16 +714,14 @@ int mkdwarfs_main(int argc, sys_char** argv, iolayer const& iol) {
|
|||||||
metadata_hdr, l_mc, "Size/Step Order")
|
metadata_hdr, l_mc, "Size/Step Order")
|
||||||
<< " " << sep << "\n";
|
<< " " << sep << "\n";
|
||||||
|
|
||||||
int level = 0;
|
for (auto const& [i, l] : folly::enumerate(levels)) {
|
||||||
for (auto const& l : levels) {
|
|
||||||
iol.out << fmt::format(" {:1d} {:2d} {:{}s} {:{}s} {:{}s}"
|
iol.out << fmt::format(" {:1d} {:2d} {:{}s} {:{}s} {:{}s}"
|
||||||
" {:2d} / {:1d} {:{}s}",
|
" {:2d} / {:1d} {:{}s}",
|
||||||
level, l.block_size_bits, l.data_compression, l_dc,
|
i, l.block_size_bits, l.data_compression, l_dc,
|
||||||
l.schema_history_compression, l_sc,
|
l.schema_history_compression, l_sc,
|
||||||
l.metadata_compression, l_mc, l.window_size,
|
l.metadata_compression, l_mc, l.window_size,
|
||||||
l.window_step, l.order, l_or)
|
l.window_step, l.order, l_or)
|
||||||
<< "\n";
|
<< "\n";
|
||||||
++level;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
iol.out << " " << sep << "\n";
|
iol.out << " " << sep << "\n";
|
||||||
|
@ -138,7 +138,6 @@ TEST_P(options_test, cache_stress) {
|
|||||||
|
|
||||||
auto const& cache_opts = GetParam();
|
auto const& cache_opts = GetParam();
|
||||||
|
|
||||||
std::mt19937_64 rng{42};
|
|
||||||
auto os = std::make_shared<test::os_access_mock>();
|
auto os = std::make_shared<test::os_access_mock>();
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -222,6 +221,7 @@ TEST_P(options_test, cache_stress) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
std::vector<std::vector<read_request>> data(num_threads);
|
std::vector<std::vector<read_request>> data(num_threads);
|
||||||
|
std::mt19937_64 rng{42};
|
||||||
|
|
||||||
for (auto& reqs : data) {
|
for (auto& reqs : data) {
|
||||||
while (reqs.size() < num_read_reqs) {
|
while (reqs.size() < num_read_reqs) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user