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

Userland: Prefer _string over _short_string

As `_string` can't fail anymore (since 3434412), there are no real
benefits to use the short variant in most cases.
This commit is contained in:
Lucas CHOLLET 2023-08-07 22:26:17 -04:00 committed by Andreas Kling
parent a5edc9cdfc
commit 3f35ffb648
198 changed files with 684 additions and 684 deletions

View file

@ -46,7 +46,7 @@ static ThrowCompletionOr<NonnullGCPtr<AsyncGenerator>> async_generator_validate(
// 4. If generator.[[GeneratorBrand]] is not generatorBrand, throw a TypeError exception.
if (async_generator.generator_brand() != generator_brand)
return vm.throw_completion<TypeError>(ErrorType::GeneratorBrandMismatch, async_generator.generator_brand().value_or("emp"_short_string), generator_brand.value_or("emp"_short_string));
return vm.throw_completion<TypeError>(ErrorType::GeneratorBrandMismatch, async_generator.generator_brand().value_or("emp"_string), generator_brand.value_or("emp"_string));
// 5. Return unused.
return async_generator;

View file

@ -1233,7 +1233,7 @@ ThrowCompletionOr<RawFormatResult> to_raw_fixed(VM& vm, MathematicalValue const&
// 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()
? "0"_short_string
? "0"_string
: MUST_OR_THROW_OOM(n.to_string(vm));
// 8. If f ≠ 0, then

View file

@ -450,9 +450,9 @@ JS_DEFINE_NATIVE_FUNCTION(NumberPrototype::to_string)
if (number_value.is_negative_infinity())
return MUST_OR_THROW_OOM(PrimitiveString::create(vm, "-Infinity"sv));
if (number_value.is_nan())
return PrimitiveString::create(vm, "NaN"_short_string);
return PrimitiveString::create(vm, "NaN"_string);
if (number_value.is_positive_zero() || number_value.is_negative_zero())
return PrimitiveString::create(vm, "0"_short_string);
return PrimitiveString::create(vm, "0"_string);
double number = number_value.as_double();
bool negative = number < 0;

View file

@ -638,7 +638,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
auto string = TRY(this_object.to_utf16_string(vm));
// 4. Let rx be ? RegExpCreate(regexp, "g").
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g"_short_string)));
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g"_string)));
// 5. Return ? Invoke(rx, @@matchAll, « S »).
return TRY(Value(rx).invoke(vm, vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string))));
@ -655,7 +655,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::normalize)
// 3. If form is undefined, let f be "NFC".
if (auto form_value = vm.argument(0); form_value.is_undefined()) {
form = "NFC"_short_string;
form = "NFC"_string;
}
// 4. Else, let f be ? ToString(form).
else {

View file

@ -1269,7 +1269,7 @@ ThrowCompletionOr<ISODateTime> parse_iso_date_time(VM& vm, ParseResult const& pa
}
// 7. Let yearMV be ! ToIntegerOrInfinity(CodePointsToString(year)).
auto year_mv = *normalized_year.value_or("0"_short_string).to_number<i32>();
auto year_mv = *normalized_year.value_or("0"_string).to_number<i32>();
// 8. If month is empty, then
// a. Let monthMV be 1.

View file

@ -824,7 +824,7 @@ ThrowCompletionOr<ISODateRecord> iso_date_from_fields(VM& vm, Object const& fiel
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "year", "day" »).
auto* prepared_fields = TRY(prepare_temporal_fields(vm, fields,
{ "day"_short_string,
{ "day"_string,
"month"_string,
"monthCode"_string,
"year"_string },
@ -890,7 +890,7 @@ ThrowCompletionOr<ISOMonthDay> iso_month_day_from_fields(VM& vm, Object const& f
// 2. Set fields to ? PrepareTemporalFields(fields, « "day", "month", "monthCode", "year" », « "day" »).
auto* prepared_fields = TRY(prepare_temporal_fields(vm, fields,
{ "day"_short_string,
{ "day"_string,
"month"_string,
"monthCode"_string,
"year"_string },

View file

@ -216,7 +216,7 @@ JS_DEFINE_NATIVE_FUNCTION(CalendarPrototype::date_until)
// 8. If largestUnit is "auto", set largestUnit to "day".
if (largest_unit == "auto")
largest_unit = "day"_short_string;
largest_unit = "day"_string;
// 9. Let result be DifferenceISODate(one.[[ISOYear]], one.[[ISOMonth]], one.[[ISODay]], two.[[ISOYear]], two.[[ISOMonth]], two.[[ISODay]], largestUnit).
auto result = difference_iso_date(vm, one->iso_year(), one->iso_month(), one->iso_day(), two->iso_year(), two->iso_month(), two->iso_day(), *largest_unit);

View file

@ -267,7 +267,7 @@ ThrowCompletionOr<String> temporal_instant_to_string(VM& vm, Instant& instant, V
// 8. If timeZone is undefined, then
if (time_zone.is_undefined()) {
// a. Let timeZoneString be "Z".
time_zone_string = "Z"_short_string;
time_zone_string = "Z"_string;
}
// 9. Else,
else {