1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:37:34 +00:00

AK+Everywhere: Rename String to DeprecatedString

We have a new, improved string type coming up in AK (OOM aware, no null
state), and while it's going to use UTF-8, the name UTF8String is a
mouthful - so let's free up the String name by renaming the existing
class.
Making the old one have an annoying name will hopefully also help with
quick adoption :^)
This commit is contained in:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -494,10 +494,10 @@ FormatResult format_numeric_to_string(NumberFormatBase const& intl_object, Mathe
// 14. If int < minInteger, then
if (digits < min_integer) {
// a. Let forwardZeros be the String consisting of minIntegerint occurrences of the character "0".
auto forward_zeros = String::repeated('0', min_integer - digits);
auto forward_zeros = DeprecatedString::repeated('0', min_integer - digits);
// b. Set string to the string-concatenation of forwardZeros and string.
string = String::formatted("{}{}", forward_zeros, string);
string = DeprecatedString::formatted("{}{}", forward_zeros, string);
}
// 15. If isNegative and x is 0, then
@ -522,7 +522,7 @@ Vector<PatternPartition> partition_number_pattern(VM& vm, NumberFormat& number_f
// 1. Let exponent be 0.
int exponent = 0;
String formatted_string;
DeprecatedString formatted_string;
// 2. If x is not-a-number, then
if (number.is_nan()) {
@ -714,7 +714,7 @@ static Vector<StringView> separate_integer_into_groups(::Locale::NumberGroupings
// 15.5.5 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/ecma402/#sec-partitionnotationsubpattern
// 1.1.7 PartitionNotationSubPattern ( numberFormat, x, n, exponent ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-partitionnotationsubpattern
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, String formatted_string, int exponent)
Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_format, MathematicalValue const& number, DeprecatedString formatted_string, int exponent)
{
// 1. Let result be a new empty List.
Vector<PatternPartition> result;
@ -885,7 +885,7 @@ Vector<PatternPartition> partition_notation_sub_pattern(NumberFormat& number_for
}
// 15.5.6 FormatNumeric ( numberFormat, x ), https://tc39.es/ecma402/#sec-formatnumber
String format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
DeprecatedString format_numeric(VM& vm, NumberFormat& number_format, MathematicalValue number)
{
// 1. Let parts be ? PartitionNumberPattern(numberFormat, x).
// Note: Our implementation of PartitionNumberPattern does not throw.
@ -941,7 +941,7 @@ Array* format_numeric_to_parts(VM& vm, NumberFormat& number_format, Mathematical
return result;
}
static String cut_trailing_zeroes(StringView string, int cut)
static DeprecatedString cut_trailing_zeroes(StringView string, int cut)
{
// These steps are exactly the same between ToRawPrecision and ToRawFixed.
@ -1022,7 +1022,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 2. If x = 0, then
if (number.is_zero()) {
// a. Let m be the String consisting of p occurrences of the character "0".
result.formatted_string = String::repeated('0', precision);
result.formatted_string = DeprecatedString::repeated('0', precision);
// b. Let e be 0.
exponent = 0;
@ -1073,10 +1073,10 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 4. If e ≥ p1, then
if (exponent >= (precision - 1)) {
// a. Let m be the string-concatenation of m and ep+1 occurrences of the character "0".
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"{}{}",
result.formatted_string,
String::repeated('0', exponent - precision + 1));
DeprecatedString::repeated('0', exponent - precision + 1));
// b. Let int be e+1.
result.digits = exponent + 1;
@ -1084,7 +1084,7 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
// 5. Else if e ≥ 0, then
else if (exponent >= 0) {
// a. Let m be the string-concatenation of the first e+1 characters of m, the character ".", and the remaining p(e+1) characters of m.
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"{}.{}",
result.formatted_string.substring_view(0, exponent + 1),
result.formatted_string.substring_view(exponent + 1));
@ -1096,9 +1096,9 @@ RawFormatResult to_raw_precision(MathematicalValue const& number, int min_precis
else {
// a. Assert: e < 0.
// b. Let m be the string-concatenation of "0.", (e+1) occurrences of the character "0", and m.
result.formatted_string = String::formatted(
result.formatted_string = DeprecatedString::formatted(
"0.{}{}",
String::repeated('0', -1 * (exponent + 1)),
DeprecatedString::repeated('0', -1 * (exponent + 1)),
result.formatted_string);
// c. Let int be 1.
@ -1206,7 +1206,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
}
// 7. If n = 0, let m be "0". Otherwise, let m be the String consisting of the digits of the decimal representation of n (in order, with no leading zeroes).
result.formatted_string = n.is_zero() ? String("0"sv) : n.to_string();
result.formatted_string = n.is_zero() ? DeprecatedString("0"sv) : n.to_string();
// 8. If f ≠ 0, then
if (fraction != 0) {
@ -1216,10 +1216,10 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
// b. If k ≤ f, then
if (decimals <= static_cast<size_t>(fraction)) {
// i. Let z be the String value consisting of f+1k occurrences of the character "0".
auto zeroes = String::repeated('0', fraction + 1 - decimals);
auto zeroes = DeprecatedString::repeated('0', fraction + 1 - decimals);
// ii. Let m be the string-concatenation of z and m.
result.formatted_string = String::formatted("{}{}", zeroes, result.formatted_string);
result.formatted_string = DeprecatedString::formatted("{}{}", zeroes, result.formatted_string);
// iii. Let k be f+1.
decimals = fraction + 1;
@ -1230,7 +1230,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
auto b = result.formatted_string.substring_view(decimals - fraction, fraction);
// d. Let m be the string-concatenation of a, ".", and b.
result.formatted_string = String::formatted("{}.{}", a, b);
result.formatted_string = DeprecatedString::formatted("{}.{}", a, b);
// e. Let int be the number of characters in a.
result.digits = a.length();
@ -1253,7 +1253,7 @@ RawFormatResult to_raw_fixed(MathematicalValue const& number, int min_fraction,
// 15.5.11 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/ecma402/#sec-getnumberformatpattern
// 1.1.14 GetNumberFormatPattern ( numberFormat, x ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-getnumberformatpattern
Optional<Variant<StringView, String>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
Optional<Variant<StringView, DeprecatedString>> get_number_format_pattern(VM& vm, NumberFormat& number_format, MathematicalValue const& number, ::Locale::NumberFormat& found_pattern)
{
// 1. Let localeData be %NumberFormat%.[[LocaleData]].
// 2. Let dataLocale be numberFormat.[[DataLocale]].
@ -1797,7 +1797,7 @@ Vector<PatternPartitionWithSource> collapse_number_range(Vector<PatternPartition
}
// 1.1.24 FormatNumericRange( numberFormat, x, y ), https://tc39.es/proposal-intl-numberformat-v3/out/numberformat/proposed.html#sec-formatnumericrange
ThrowCompletionOr<String> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
ThrowCompletionOr<DeprecatedString> format_numeric_range(VM& vm, NumberFormat& number_format, MathematicalValue start, MathematicalValue end)
{
// 1. Let parts be ? PartitionNumberRangePattern(numberFormat, x, y).
auto parts = TRY(partition_number_range_pattern(vm, number_format, move(start), move(end)));