LibJS: Convert short string literal PrimitiveString instances to String

This commit is contained in:
Timothy Flynn 2023-02-09 09:15:02 -05:00 committed by Linus Groh
parent 49e8dcf0b2
commit 69a56a8e39
Notes: sideshowbarker 2024-07-17 08:34:29 +09:00
2 changed files with 3 additions and 3 deletions

View file

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

View file

@ -494,7 +494,7 @@ JS_DEFINE_NATIVE_FUNCTION(StringPrototype::match_all)
auto string = TRY(this_object.to_utf16_string(vm));
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, "g")));
auto rx = TRY(regexp_create(vm, regexp, PrimitiveString::create(vm, String::from_utf8_short_string("g"sv))));
return TRY(Value(rx).invoke(vm, *vm.well_known_symbol_match_all(), PrimitiveString::create(vm, move(string))));
}