Commit 5ba95354 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[cleanup] Use factory->*string() where possible

Replace several NewStringFromStaticChars calls with the explicit root
string access.

Bug: v8:9396
Change-Id: I381e676fa81de24e892afe703b804b7c724a6083
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1774719Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63429}
parent 888f1b4a
......@@ -4883,7 +4883,7 @@ Local<Value> Function::GetDisplayName() const {
}
auto func = i::Handle<i::JSFunction>::cast(self);
i::Handle<i::String> property_name =
isolate->factory()->NewStringFromStaticChars("displayName");
isolate->factory()->display_name_string();
i::Handle<i::Object> value =
i::JSReceiver::GetDataProperty(func, property_name);
if (value->IsString()) {
......
......@@ -91,7 +91,7 @@ MaybeHandle<BigInt> ThisBigIntValue(Isolate* isolate, Handle<Object> value,
isolate,
NewTypeError(MessageTemplate::kNotGeneric,
isolate->factory()->NewStringFromAsciiChecked(caller),
isolate->factory()->NewStringFromStaticChars("BigInt")),
isolate->factory()->BigInt_string()),
BigInt);
}
......
......@@ -208,14 +208,10 @@ BUILTIN(StringPrototypeNormalize) {
ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, form,
Object::ToString(isolate, form_input));
if (!(String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFC")) ||
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFD")) ||
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKC")) ||
String::Equals(isolate, form,
isolate->factory()->NewStringFromStaticChars("NFKD")))) {
if (!(String::Equals(isolate, form, isolate->factory()->NFC_string()) ||
String::Equals(isolate, form, isolate->factory()->NFD_string()) ||
String::Equals(isolate, form, isolate->factory()->NFKC_string()) ||
String::Equals(isolate, form, isolate->factory()->NFKD_string()))) {
Handle<String> valid_forms =
isolate->factory()->NewStringFromStaticChars("NFC, NFD, NFKC, NFKD");
THROW_NEW_ERROR_RETURN_FAILURE(
......
......@@ -992,7 +992,7 @@ ComparisonResult BigInt::CompareToDouble(Handle<BigInt> x, double y) {
MaybeHandle<String> BigInt::ToString(Isolate* isolate, Handle<BigInt> bigint,
int radix, ShouldThrow should_throw) {
if (bigint->is_zero()) {
return isolate->factory()->NewStringFromStaticChars("0");
return isolate->factory()->zero_string();
}
if (base::bits::IsPowerOfTwo(radix)) {
return MutableBigInt::ToStringBasePowerOfTwo(isolate, bigint, radix,
......
......@@ -1036,7 +1036,7 @@ MaybeHandle<JSNumberFormat> JSNumberFormat::New(Isolate* isolate,
isolate,
NewTypeError(MessageTemplate::kInvalidUnit,
factory->NewStringFromStaticChars("Intl.NumberFormat"),
factory->NewStringFromStaticChars("")),
factory->empty_string()),
JSNumberFormat);
}
......
......@@ -207,7 +207,7 @@ Maybe<bool> JSSegmentIterator::Following(
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"),
factory->from_string(),
factory->NewStringFromStaticChars("following"), index),
Nothing<bool>());
}
......@@ -220,7 +220,7 @@ Maybe<bool> JSSegmentIterator::Following(
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"),
factory->from_string(),
factory->NewStringFromStaticChars("following"),
from_obj),
Nothing<bool>());
......@@ -260,7 +260,7 @@ Maybe<bool> JSSegmentIterator::Preceding(
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"),
factory->from_string(),
factory->NewStringFromStaticChars("preceding"), index),
Nothing<bool>());
}
......@@ -272,7 +272,7 @@ Maybe<bool> JSSegmentIterator::Preceding(
THROW_NEW_ERROR_RETURN_VALUE(
isolate,
NewRangeError(MessageTemplate::kParameterOfFunctionOutOfRange,
factory->NewStringFromStaticChars("from"),
factory->from_string(),
factory->NewStringFromStaticChars("preceding"),
from_obj),
Nothing<bool>());
......
......@@ -695,7 +695,7 @@ RUNTIME_FUNCTION(Runtime_DebugCollectCoverage) {
int num_scripts = static_cast<int>(coverage->size());
// Prepare property keys.
Handle<FixedArray> scripts_array = factory->NewFixedArray(num_scripts);
Handle<String> script_string = factory->NewStringFromStaticChars("script");
Handle<String> script_string = factory->script_string();
for (int i = 0; i < num_scripts; i++) {
const auto& script_data = coverage->at(i);
HandleScope inner_scope(isolate);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment