mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:44:58 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <AK/NumericLimits.h>
|
||||
#include <AK/StringView.h>
|
||||
|
@ -13,7 +13,7 @@
|
|||
namespace AK {
|
||||
|
||||
// FIXME: Remove this hackery once printf() supports floats.
|
||||
static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator)
|
||||
static ByteString number_string_with_one_decimal(u64 number, u64 unit, StringView suffix, UseThousandsSeparator use_thousands_separator)
|
||||
{
|
||||
constexpr auto max_unit_size = NumericLimits<u64>::max() / 10;
|
||||
VERIFY(unit < max_unit_size);
|
||||
|
@ -21,25 +21,25 @@ static DeprecatedString number_string_with_one_decimal(u64 number, u64 unit, Str
|
|||
auto integer_part = number / unit;
|
||||
auto decimal_part = (number % unit) * 10 / unit;
|
||||
if (use_thousands_separator == UseThousandsSeparator::Yes)
|
||||
return DeprecatedString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix);
|
||||
return ByteString::formatted("{:'d}.{} {}", integer_part, decimal_part, suffix);
|
||||
|
||||
return DeprecatedString::formatted("{}.{} {}", integer_part, decimal_part, suffix);
|
||||
return ByteString::formatted("{}.{} {}", integer_part, decimal_part, suffix);
|
||||
}
|
||||
|
||||
DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator)
|
||||
ByteString human_readable_quantity(u64 quantity, HumanReadableBasedOn based_on, StringView unit, UseThousandsSeparator use_thousands_separator)
|
||||
{
|
||||
u64 size_of_unit = based_on == HumanReadableBasedOn::Base2 ? 1024 : 1000;
|
||||
constexpr auto unit_prefixes = AK::Array { "", "K", "M", "G", "T", "P", "E" };
|
||||
auto full_unit_suffix = [&](int index) {
|
||||
auto binary_infix = (based_on == HumanReadableBasedOn::Base2 && index != 0) ? "i"sv : ""sv;
|
||||
return DeprecatedString::formatted("{}{}{}",
|
||||
return ByteString::formatted("{}{}{}",
|
||||
unit_prefixes[index], binary_infix, unit);
|
||||
};
|
||||
|
||||
auto size_of_current_unit = size_of_unit;
|
||||
|
||||
if (quantity < size_of_unit)
|
||||
return DeprecatedString::formatted("{} {}", quantity, full_unit_suffix(0));
|
||||
return ByteString::formatted("{} {}", quantity, full_unit_suffix(0));
|
||||
|
||||
for (size_t i = 1; i < unit_prefixes.size() - 1; i++) {
|
||||
auto suffix = full_unit_suffix(i);
|
||||
|
@ -54,28 +54,28 @@ DeprecatedString human_readable_quantity(u64 quantity, HumanReadableBasedOn base
|
|||
size_of_current_unit, full_unit_suffix(unit_prefixes.size() - 1), use_thousands_separator);
|
||||
}
|
||||
|
||||
DeprecatedString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator)
|
||||
ByteString human_readable_size(u64 size, HumanReadableBasedOn based_on, UseThousandsSeparator use_thousands_separator)
|
||||
{
|
||||
return human_readable_quantity(size, based_on, "B"sv, use_thousands_separator);
|
||||
}
|
||||
|
||||
DeprecatedString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator)
|
||||
ByteString human_readable_size_long(u64 size, UseThousandsSeparator use_thousands_separator)
|
||||
{
|
||||
if (size < 1 * KiB) {
|
||||
if (use_thousands_separator == UseThousandsSeparator::Yes)
|
||||
return DeprecatedString::formatted("{:'d} bytes", size);
|
||||
return ByteString::formatted("{:'d} bytes", size);
|
||||
|
||||
return DeprecatedString::formatted("{} bytes", size);
|
||||
return ByteString::formatted("{} bytes", size);
|
||||
}
|
||||
|
||||
auto human_readable_size_string = human_readable_size(size, HumanReadableBasedOn::Base2, use_thousands_separator);
|
||||
if (use_thousands_separator == UseThousandsSeparator::Yes)
|
||||
return DeprecatedString::formatted("{} ({:'d} bytes)", human_readable_size_string, size);
|
||||
return ByteString::formatted("{} ({:'d} bytes)", human_readable_size_string, size);
|
||||
|
||||
return DeprecatedString::formatted("{} ({} bytes)", human_readable_size_string, size);
|
||||
return ByteString::formatted("{} ({} bytes)", human_readable_size_string, size);
|
||||
}
|
||||
|
||||
DeprecatedString human_readable_time(i64 time_in_seconds)
|
||||
ByteString human_readable_time(i64 time_in_seconds)
|
||||
{
|
||||
auto days = time_in_seconds / 86400;
|
||||
time_in_seconds = time_in_seconds % 86400;
|
||||
|
@ -99,10 +99,10 @@ DeprecatedString human_readable_time(i64 time_in_seconds)
|
|||
|
||||
builder.appendff("{} second{}", time_in_seconds, time_in_seconds == 1 ? "" : "s");
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
DeprecatedString human_readable_digital_time(i64 time_in_seconds)
|
||||
ByteString human_readable_digital_time(i64 time_in_seconds)
|
||||
{
|
||||
auto hours = time_in_seconds / 3600;
|
||||
time_in_seconds = time_in_seconds % 3600;
|
||||
|
@ -117,7 +117,7 @@ DeprecatedString human_readable_digital_time(i64 time_in_seconds)
|
|||
builder.appendff("{:02}:", minutes);
|
||||
builder.appendff("{:02}", time_in_seconds);
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue