mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 12:06:01 +01:00
Revert "Merge pull request #14380 from NixOS/backport-14364-to-2.30-maintenance"
This reverts commitb479a25292, reversing changes made tofc0601b153.
This commit is contained in:
parent
0cc9f0810f
commit
a6fb25f9f4
10 changed files with 30 additions and 24 deletions
|
|
@ -132,16 +132,15 @@ std::optional<N> string2Float(const std::string_view s)
|
|||
template std::optional<double> string2Float<double>(const std::string_view s);
|
||||
template std::optional<float> string2Float<float>(const std::string_view s);
|
||||
|
||||
std::string renderSize(int64_t value, bool align)
|
||||
std::string renderSize(uint64_t value, bool align)
|
||||
{
|
||||
static const std::array<char, 9> prefixes{{'K', 'K', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'}};
|
||||
size_t power = 0;
|
||||
double abs_value = std::abs(value);
|
||||
while (abs_value > 1024 && power < prefixes.size()) {
|
||||
double res = value;
|
||||
while (res > 1024 && power < prefixes.size()) {
|
||||
++power;
|
||||
abs_value /= 1024;
|
||||
res /= 1024;
|
||||
}
|
||||
double res = (double) value / std::pow(1024.0, power);
|
||||
return fmt(align ? "%6.1f %ciB" : "%.1f %ciB", power == 0 ? res / 1024 : res, prefixes.at(power));
|
||||
}
|
||||
|
||||
|
|
@ -317,4 +316,9 @@ 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