mirror of
https://github.com/NixOS/nix.git
synced 2025-11-08 11:36:03 +01:00
refactor(libutil): remove showBytes() in favor of renderSize()
The `showBytes()` function was redundant with `renderSize()` as the latter automatically selects the appropriate unit (KiB, MiB, GiB, etc.) based on the value, whereas `showBytes()` always formatted as MiB regardless of size. Co-authored-by: Bernardo Meurer Costa <beme@anthropic.com>
This commit is contained in:
parent
9d4d10954a
commit
f234633e27
5 changed files with 2 additions and 11 deletions
|
|
@ -89,8 +89,6 @@ extern volatile ::sig_atomic_t blockInt;
|
|||
|
||||
/* GC helpers. */
|
||||
|
||||
std::string showBytes(uint64_t bytes);
|
||||
|
||||
struct GCResults;
|
||||
|
||||
struct PrintFreed
|
||||
|
|
|
|||
|
|
@ -406,7 +406,7 @@ RunPager::~RunPager()
|
|||
PrintFreed::~PrintFreed()
|
||||
{
|
||||
if (show)
|
||||
std::cout << fmt("%d store paths deleted, %s freed\n", results.paths.size(), showBytes(results.bytesFreed));
|
||||
std::cout << fmt("%d store paths deleted, %s freed\n", results.paths.size(), renderSize(results.bytesFreed));
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ void LocalStore::optimiseStore()
|
|||
|
||||
optimiseStore(stats);
|
||||
|
||||
printInfo("%s freed by hard-linking %d files", showBytes(stats.bytesFreed), stats.filesLinked);
|
||||
printInfo("%s freed by hard-linking %d files", renderSize(stats.bytesFreed), stats.filesLinked);
|
||||
}
|
||||
|
||||
void LocalStore::optimisePath(const Path & path, RepairFlag repair)
|
||||
|
|
|
|||
|
|
@ -333,8 +333,6 @@ struct overloaded : Ts...
|
|||
template<class... Ts>
|
||||
overloaded(Ts...) -> overloaded<Ts...>;
|
||||
|
||||
std::string showBytes(uint64_t bytes);
|
||||
|
||||
/**
|
||||
* Provide an addition operator between strings and string_views
|
||||
* inexplicably omitted from the standard library.
|
||||
|
|
|
|||
|
|
@ -257,9 +257,4 @@ std::pair<std::string_view, std::string_view> getLine(std::string_view s)
|
|||
}
|
||||
}
|
||||
|
||||
std::string showBytes(uint64_t bytes)
|
||||
{
|
||||
return fmt("%.2f MiB", bytes / (1024.0 * 1024.0));
|
||||
}
|
||||
|
||||
} // namespace nix
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue