mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:17:45 +00:00
Everywhere: Add sv suffix to strings relying on StringView(char const*)
Each of these strings would previously rely on StringView's char const* constructor overload, which would call __builtin_strlen on the string. Since we now have operator ""sv, we can replace these with much simpler versions. This opens the door to being able to remove StringView(char const*). No functional changes.
This commit is contained in:
parent
e5f09ea170
commit
3f3f45580a
762 changed files with 8315 additions and 8316 deletions
|
@ -30,6 +30,6 @@ template<>
|
|||
struct AK::Formatter<JS::Bytecode::Label> : AK::Formatter<FormatString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Label const& value)
|
||||
{
|
||||
return AK::Formatter<FormatString>::format(builder, "@{}", value.block().name());
|
||||
return AK::Formatter<FormatString>::format(builder, "@{}"sv, value.block().name());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -759,7 +759,7 @@ ThrowCompletionOr<void> NewClass::execute_impl(Bytecode::Interpreter& interprete
|
|||
auto name = m_class_expression.name();
|
||||
auto scope = interpreter.ast_interpreter_scope();
|
||||
auto& ast_interpreter = scope.interpreter();
|
||||
auto class_object = TRY(m_class_expression.class_definition_evaluation(ast_interpreter, interpreter.global_object(), name, name.is_null() ? "" : name));
|
||||
auto class_object = TRY(m_class_expression.class_definition_evaluation(ast_interpreter, interpreter.global_object(), name, name.is_null() ? ""sv : name));
|
||||
interpreter.accumulator() = class_object;
|
||||
return {};
|
||||
}
|
||||
|
@ -810,7 +810,7 @@ String NewBigInt::to_string_impl(Bytecode::Executable const&) const
|
|||
String NewArray::to_string_impl(Bytecode::Executable const&) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("NewArray");
|
||||
builder.append("NewArray"sv);
|
||||
if (m_element_count != 0) {
|
||||
builder.appendff(" [{}-{}]", m_elements[0], m_elements[1]);
|
||||
}
|
||||
|
@ -842,7 +842,7 @@ String CopyObjectExcludingProperties::to_string_impl(Bytecode::Executable const&
|
|||
StringBuilder builder;
|
||||
builder.appendff("CopyObjectExcludingProperties from:{}", m_from_object);
|
||||
if (m_excluded_names_count != 0) {
|
||||
builder.append(" excluding:[");
|
||||
builder.append(" excluding:["sv);
|
||||
for (size_t i = 0; i < m_excluded_names_count; ++i) {
|
||||
builder.appendff("{}", m_excluded_names[i]);
|
||||
if (i != m_excluded_names_count - 1)
|
||||
|
@ -950,7 +950,7 @@ String Call::to_string_impl(Bytecode::Executable const&) const
|
|||
StringBuilder builder;
|
||||
builder.appendff("Call callee:{}, this:{}", m_callee, m_this_value);
|
||||
if (m_argument_count != 0) {
|
||||
builder.append(", arguments:[");
|
||||
builder.append(", arguments:["sv);
|
||||
for (size_t i = 0; i < m_argument_count; ++i) {
|
||||
builder.appendff("{}", m_arguments[i]);
|
||||
if (i != m_argument_count - 1)
|
||||
|
@ -1024,14 +1024,14 @@ String ContinuePendingUnwind::to_string_impl(Bytecode::Executable const&) const
|
|||
String PushDeclarativeEnvironment::to_string_impl(Bytecode::Executable const& executable) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("PushDeclarativeEnvironment");
|
||||
builder.append("PushDeclarativeEnvironment"sv);
|
||||
if (!m_variables.is_empty()) {
|
||||
builder.append(" {");
|
||||
builder.append(" {"sv);
|
||||
Vector<String> names;
|
||||
for (auto& it : m_variables)
|
||||
names.append(executable.get_string(it.key));
|
||||
builder.join(", ", names);
|
||||
builder.append("}");
|
||||
builder.join(", "sv, names);
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@ void MergeBlocks::perform(PassPipelineExecutable& executable)
|
|||
|
||||
size_t size = 0;
|
||||
StringBuilder builder;
|
||||
builder.append("merge");
|
||||
builder.append("merge"sv);
|
||||
for (auto& entry : successors) {
|
||||
size += entry->size();
|
||||
builder.append('.');
|
||||
|
|
|
@ -45,7 +45,7 @@ struct AK::Formatter<JS::Bytecode::Register> : AK::Formatter<FormatString> {
|
|||
ErrorOr<void> format(FormatBuilder& builder, JS::Bytecode::Register const& value)
|
||||
{
|
||||
if (value.index() == JS::Bytecode::Register::accumulator_index)
|
||||
return AK::Formatter<FormatString>::format(builder, "acc");
|
||||
return AK::Formatter<FormatString>::format(builder, "${}", value.index());
|
||||
return builder.put_string("acc"sv);
|
||||
return AK::Formatter<FormatString>::format(builder, "${}"sv, value.index());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -464,14 +464,14 @@ ThrowCompletionOr<String> Console::format_time_since(Core::ElapsedTimer timer)
|
|||
};
|
||||
StringBuilder builder;
|
||||
if (duration.days > 0)
|
||||
append(builder, "{:.0} day(s)", duration.days);
|
||||
append(builder, "{:.0} day(s)"sv, duration.days);
|
||||
if (duration.hours > 0)
|
||||
append(builder, "{:.0} hour(s)", duration.hours);
|
||||
append(builder, "{:.0} hour(s)"sv, duration.hours);
|
||||
if (duration.minutes > 0)
|
||||
append(builder, "{:.0} minute(s)", duration.minutes);
|
||||
append(builder, "{:.0} minute(s)"sv, duration.minutes);
|
||||
if (duration.seconds > 0 || duration.milliseconds > 0) {
|
||||
double combined_seconds = duration.seconds + (0.001 * duration.milliseconds);
|
||||
append(builder, "{:.3} seconds", combined_seconds);
|
||||
append(builder, "{:.3} seconds"sv, combined_seconds);
|
||||
}
|
||||
|
||||
return builder.to_string();
|
||||
|
|
|
@ -66,7 +66,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_linking(VM& vm, Vector<Module*
|
|||
// b. Return index.
|
||||
// Note: Step 1, 1.a and 1.b are handled in Module.cpp
|
||||
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_linking[{}](vm, {}, {})", this, String::join(",", stack), index);
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_linking[{}](vm, {}, {})", this, String::join(',', stack), index);
|
||||
|
||||
// 2. If module.[[Status]] is linking, linked, evaluating-async, or evaluated, then
|
||||
if (m_status == ModuleStatus::Linking || m_status == ModuleStatus::Linked || m_status == ModuleStatus::EvaluatingAsync || m_status == ModuleStatus::Evaluated) {
|
||||
|
@ -96,7 +96,7 @@ ThrowCompletionOr<u32> CyclicModule::inner_module_linking(VM& vm, Vector<Module*
|
|||
StringBuilder request_module_names;
|
||||
for (auto& module_request : m_requested_modules) {
|
||||
request_module_names.append(module_request.module_specifier);
|
||||
request_module_names.append(", ");
|
||||
request_module_names.append(", "sv);
|
||||
}
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] module: {} has requested modules: [{}]", filename(), request_module_names.string_view());
|
||||
#endif
|
||||
|
@ -263,7 +263,7 @@ ThrowCompletionOr<Promise*> CyclicModule::evaluate(VM& vm)
|
|||
// 16.2.1.5.2.1 InnerModuleEvaluation ( module, stack, index ), https://tc39.es/ecma262/#sec-innermoduleevaluation
|
||||
ThrowCompletionOr<u32> CyclicModule::inner_module_evaluation(VM& vm, Vector<Module*>& stack, u32 index)
|
||||
{
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_evaluation[{}](vm, {}, {})", this, String::join(", ", stack), index);
|
||||
dbgln_if(JS_MODULE_DEBUG, "[JS MODULE] inner_module_evaluation[{}](vm, {}, {})", this, String::join(", "sv, stack), index);
|
||||
// Note: Step 1 is performed in Module.cpp
|
||||
|
||||
// 2. If module.[[Status]] is evaluating-async or evaluated, then
|
||||
|
|
|
@ -830,7 +830,7 @@ Token Lexer::next()
|
|||
if (m_hit_invalid_unicode.has_value()) {
|
||||
value_start = m_hit_invalid_unicode.value() - 1;
|
||||
m_current_token = Token(TokenType::Invalid, "Invalid unicode codepoint in source",
|
||||
"", // Since the invalid unicode can occur anywhere in the current token the trivia is not correct
|
||||
""sv, // Since the invalid unicode can occur anywhere in the current token the trivia is not correct
|
||||
m_source.substring_view(value_start + 1, min(4u, m_source.length() - value_start - 2)),
|
||||
m_filename,
|
||||
m_line_number,
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace JS {
|
|||
|
||||
class Lexer {
|
||||
public:
|
||||
explicit Lexer(StringView source, StringView filename = "(unknown)", size_t line_number = 1, size_t line_column = 0);
|
||||
explicit Lexer(StringView source, StringView filename = "(unknown)"sv, size_t line_number = 1, size_t line_column = 0);
|
||||
|
||||
Token next();
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@ String MarkupGenerator::html_from_error(Object& object)
|
|||
void MarkupGenerator::value_to_html(Value value, StringBuilder& output_html, HashTable<Object*> seen_objects)
|
||||
{
|
||||
if (value.is_empty()) {
|
||||
output_html.append("<empty>");
|
||||
output_html.append("<empty>"sv);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void MarkupGenerator::value_to_html(Value value, StringBuilder& output_html, Has
|
|||
if (value.is_string())
|
||||
output_html.append('"');
|
||||
|
||||
output_html.append("</span>");
|
||||
output_html.append("</span>"sv);
|
||||
}
|
||||
|
||||
void MarkupGenerator::array_to_html(Array const& array, StringBuilder& html_output, HashTable<Object*>& seen_objects)
|
||||
|
|
|
@ -682,7 +682,7 @@ bool Parser::match_invalid_escaped_keyword() const
|
|||
return token_value != "let"sv;
|
||||
}
|
||||
|
||||
static constexpr AK::Array<StringView, 9> strict_reserved_words = { "implements", "interface", "let", "package", "private", "protected", "public", "static", "yield" };
|
||||
static constexpr AK::Array<StringView, 9> strict_reserved_words = { "implements"sv, "interface"sv, "let"sv, "package"sv, "private"sv, "protected"sv, "public"sv, "static"sv, "yield"sv };
|
||||
|
||||
static bool is_strict_reserved_word(StringView str)
|
||||
{
|
||||
|
@ -755,7 +755,7 @@ RefPtr<FunctionExpression> Parser::try_parse_arrow_function_expression(bool expe
|
|||
TemporaryChange in_async_context(m_state.await_expression_is_valid, is_async || m_state.await_expression_is_valid);
|
||||
|
||||
parameters = parse_formal_parameters(function_length, FunctionNodeParseOptions::IsArrowFunction | (is_async ? FunctionNodeParseOptions::IsAsyncFunction : 0));
|
||||
if (m_state.errors.size() > previous_syntax_errors && m_state.errors[previous_syntax_errors].message.starts_with("Unexpected token"))
|
||||
if (m_state.errors.size() > previous_syntax_errors && m_state.errors[previous_syntax_errors].message.starts_with("Unexpected token"sv))
|
||||
return nullptr;
|
||||
if (!match(TokenType::ParenClose))
|
||||
return nullptr;
|
||||
|
@ -1199,20 +1199,20 @@ NonnullRefPtr<ClassExpression> Parser::parse_class_expression(bool expect_class_
|
|||
switch (method_kind) {
|
||||
case ClassMethod::Kind::Method:
|
||||
if (is_async) {
|
||||
name = "async";
|
||||
name = "async"sv;
|
||||
is_async = false;
|
||||
} else {
|
||||
VERIFY(is_static);
|
||||
name = "static";
|
||||
name = "static"sv;
|
||||
is_static = false;
|
||||
}
|
||||
break;
|
||||
case ClassMethod::Kind::Getter:
|
||||
name = "get";
|
||||
name = "get"sv;
|
||||
method_kind = ClassMethod::Kind::Method;
|
||||
break;
|
||||
case ClassMethod::Kind::Setter:
|
||||
name = "set";
|
||||
name = "set"sv;
|
||||
method_kind = ClassMethod::Kind::Method;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ public:
|
|||
return {};
|
||||
// We need to modify the source to match what the lexer considers one line - normalizing
|
||||
// line terminators to \n is easier than splitting using all different LT characters.
|
||||
String source_string = source.replace("\r\n", "\n", ReplaceMode::All).replace("\r", "\n", ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n", ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n", ReplaceMode::All);
|
||||
String source_string = source.replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\n"sv, ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\n"sv, ReplaceMode::All);
|
||||
StringBuilder builder;
|
||||
builder.append(source_string.split_view('\n', true)[position.value().line - 1]);
|
||||
builder.append('\n');
|
||||
|
|
|
@ -155,7 +155,7 @@ static double parse_date_string(String const& date_string)
|
|||
|
||||
// Date.parse() is allowed to accept an arbitrary number of implementation-defined formats.
|
||||
// Parse formats of this type: "Wed Apr 17 23:08:53 +0000 2019"
|
||||
auto maybe_datetime = Core::DateTime::parse("%a %b %e %T %z %Y", date_string);
|
||||
auto maybe_datetime = Core::DateTime::parse("%a %b %e %T %z %Y"sv, date_string);
|
||||
if (maybe_datetime.has_value())
|
||||
return 1000.0 * maybe_datetime->timestamp();
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ struct Variable {
|
|||
#define JS_ENVIRONMENT(class_, base_class) \
|
||||
public: \
|
||||
using Base = base_class; \
|
||||
virtual StringView class_name() const override { return #class_; }
|
||||
virtual StringView class_name() const override { return #class_##sv; }
|
||||
|
||||
class Environment : public Cell {
|
||||
public:
|
||||
|
|
|
@ -299,7 +299,7 @@ ThrowCompletionOr<DurationUnitOptions> get_duration_unit_options(GlobalObject& g
|
|||
// here, but at some point we should split the the NumberFormat exporter to export both formats of the data.
|
||||
static String convert_number_format_pattern_to_duration_format_template(Unicode::NumberFormat const& number_format)
|
||||
{
|
||||
auto result = number_format.zero_format.replace("{number}", "{0}", ReplaceMode::FirstOnly);
|
||||
auto result = number_format.zero_format.replace("{number}"sv, "{0}"sv, ReplaceMode::FirstOnly);
|
||||
|
||||
for (size_t i = 0; i < number_format.identifiers.size(); ++i)
|
||||
result = result.replace(String::formatted("{{unitIdentifier:{}}}", i), number_format.identifiers[i], ReplaceMode::FirstOnly);
|
||||
|
@ -428,7 +428,7 @@ ThrowCompletionOr<Vector<PatternPartition>> partition_duration_format_pattern(Gl
|
|||
auto separator = Unicode::get_number_system_symbol(data_locale, duration_format.numbering_system(), Unicode::NumericSymbol::TimeSeparator).value_or(":"sv);
|
||||
|
||||
// 2. Append the new Record { [[Type]]: "literal", [[Value]]: separator} to the end of result.
|
||||
result.append({ "literal", separator });
|
||||
result.append({ "literal"sv, separator });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -254,7 +254,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_object(GlobalObject& global
|
|||
}
|
||||
StringBuilder builder;
|
||||
if (property_strings.is_empty()) {
|
||||
builder.append("{}");
|
||||
builder.append("{}"sv);
|
||||
} else {
|
||||
bool first = true;
|
||||
builder.append('{');
|
||||
|
@ -306,7 +306,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(GlobalObject& global_
|
|||
for (size_t i = 0; i < length; ++i) {
|
||||
auto serialized_property_string = TRY(serialize_json_property(global_object, state, i, &object));
|
||||
if (serialized_property_string.is_null()) {
|
||||
property_strings.append("null");
|
||||
property_strings.append("null"sv);
|
||||
} else {
|
||||
property_strings.append(serialized_property_string);
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(GlobalObject& global_
|
|||
|
||||
StringBuilder builder;
|
||||
if (property_strings.is_empty()) {
|
||||
builder.append("[]");
|
||||
builder.append("[]"sv);
|
||||
} else {
|
||||
if (state.gap.is_empty()) {
|
||||
builder.append('[');
|
||||
|
@ -327,7 +327,7 @@ ThrowCompletionOr<String> JSONObject::serialize_json_array(GlobalObject& global_
|
|||
}
|
||||
builder.append(']');
|
||||
} else {
|
||||
builder.append("[\n");
|
||||
builder.append("[\n"sv);
|
||||
builder.append(state.indent);
|
||||
auto separator = String::formatted(",\n{}", state.indent);
|
||||
bool first = true;
|
||||
|
@ -357,25 +357,25 @@ String JSONObject::quote_json_string(String string)
|
|||
for (auto code_point : utf_view) {
|
||||
switch (code_point) {
|
||||
case '\b':
|
||||
builder.append("\\b");
|
||||
builder.append("\\b"sv);
|
||||
break;
|
||||
case '\t':
|
||||
builder.append("\\t");
|
||||
builder.append("\\t"sv);
|
||||
break;
|
||||
case '\n':
|
||||
builder.append("\\n");
|
||||
builder.append("\\n"sv);
|
||||
break;
|
||||
case '\f':
|
||||
builder.append("\\f");
|
||||
builder.append("\\f"sv);
|
||||
break;
|
||||
case '\r':
|
||||
builder.append("\\r");
|
||||
builder.append("\\r"sv);
|
||||
break;
|
||||
case '"':
|
||||
builder.append("\\\"");
|
||||
builder.append("\\\""sv);
|
||||
break;
|
||||
case '\\':
|
||||
builder.append("\\\\");
|
||||
builder.append("\\\\"sv);
|
||||
break;
|
||||
default:
|
||||
if (code_point < 0x20 || Utf16View::is_high_surrogate(code_point) || Utf16View::is_low_surrogate(code_point)) {
|
||||
|
|
|
@ -30,7 +30,7 @@ public: \
|
|||
using Base = base_class; \
|
||||
virtual StringView class_name() const override \
|
||||
{ \
|
||||
return #class_; \
|
||||
return #class_##sv; \
|
||||
}
|
||||
|
||||
struct PrivateElement {
|
||||
|
|
|
@ -81,7 +81,7 @@ struct Formatter<JS::PropertyAttributes> : Formatter<StringView> {
|
|||
parts.append(String::formatted("[[Writable]]: {}", property_attributes.is_writable()));
|
||||
parts.append(String::formatted("[[Enumerable]]: {}", property_attributes.is_enumerable()));
|
||||
parts.append(String::formatted("[[Configurable]]: {}", property_attributes.is_configurable()));
|
||||
return Formatter<StringView>::format(builder, String::formatted("PropertyAttributes {{ {} }}", String::join(", ", parts)));
|
||||
return Formatter<StringView>::format(builder, String::formatted("PropertyAttributes {{ {} }}", String::join(", "sv, parts)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ struct Formatter<JS::PropertyDescriptor> : Formatter<StringView> {
|
|||
parts.append(String::formatted("[[Enumerable]]: {}", *property_descriptor.enumerable));
|
||||
if (property_descriptor.configurable.has_value())
|
||||
parts.append(String::formatted("[[Configurable]]: {}", *property_descriptor.configurable));
|
||||
return Formatter<StringView>::format(builder, String::formatted("PropertyDescriptor {{ {} }}", String::join(", ", parts)));
|
||||
return Formatter<StringView>::format(builder, String::formatted("PropertyDescriptor {{ {} }}", String::join(", "sv, parts)));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -199,24 +199,24 @@ ThrowCompletionOr<bool> Reference::delete_(GlobalObject& global_object)
|
|||
String Reference::to_string() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append("Reference { Base=");
|
||||
builder.append("Reference { Base="sv);
|
||||
switch (m_base_type) {
|
||||
case BaseType::Unresolvable:
|
||||
builder.append("Unresolvable");
|
||||
builder.append("Unresolvable"sv);
|
||||
break;
|
||||
case BaseType::Environment:
|
||||
builder.appendff("{}", base_environment().class_name());
|
||||
break;
|
||||
case BaseType::Value:
|
||||
if (m_base_value.is_empty())
|
||||
builder.append("<empty>");
|
||||
builder.append("<empty>"sv);
|
||||
else
|
||||
builder.appendff("{}", m_base_value.to_string_without_side_effects());
|
||||
break;
|
||||
}
|
||||
builder.append(", ReferencedName=");
|
||||
builder.append(", ReferencedName="sv);
|
||||
if (!m_name.is_valid())
|
||||
builder.append("<invalid>");
|
||||
builder.append("<invalid>"sv);
|
||||
else if (m_name.is_symbol())
|
||||
builder.appendff("{}", m_name.as_symbol()->to_string());
|
||||
else
|
||||
|
@ -224,11 +224,11 @@ String Reference::to_string() const
|
|||
builder.appendff(", Strict={}", m_strict);
|
||||
builder.appendff(", ThisValue=");
|
||||
if (m_this_value.is_empty())
|
||||
builder.append("<empty>");
|
||||
builder.append("<empty>"sv);
|
||||
else
|
||||
builder.appendff("{}", m_this_value.to_string_without_side_effects());
|
||||
|
||||
builder.append(" }");
|
||||
builder.append(" }"sv);
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ String RegExpObject::escape_regexp_pattern() const
|
|||
if (m_pattern.is_empty())
|
||||
return "(?:)";
|
||||
// FIXME: Check u flag and escape accordingly
|
||||
return m_pattern.replace("\n", "\\n", ReplaceMode::All).replace("\r", "\\r", ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\\u2028", ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\\u2029", ReplaceMode::All).replace("/", "\\/", ReplaceMode::All);
|
||||
return m_pattern.replace("\n"sv, "\\n"sv, ReplaceMode::All).replace("\r"sv, "\\r"sv, ReplaceMode::All).replace(LINE_SEPARATOR_STRING, "\\u2028"sv, ReplaceMode::All).replace(PARAGRAPH_SEPARATOR_STRING, "\\u2029"sv, ReplaceMode::All).replace("/"sv, "\\/"sv, ReplaceMode::All);
|
||||
}
|
||||
|
||||
// 22.2.3.2.4 RegExpCreate ( P, F ), https://tc39.es/ecma262/#sec-regexpcreate
|
||||
|
|
|
@ -474,7 +474,7 @@ JS_DEFINE_NATIVE_FUNCTION(RegExpPrototype::flags)
|
|||
#define __JS_ENUMERATE(flagName, flag_name, flag_char) \
|
||||
auto flag_##flag_name = TRY(regexp_object->get(vm.names.flagName)); \
|
||||
if (flag_##flag_name.to_boolean()) \
|
||||
builder.append(#flag_char);
|
||||
builder.append(#flag_char##sv);
|
||||
JS_ENUMERATE_REGEXP_FLAGS
|
||||
#undef __JS_ENUMERATE
|
||||
|
||||
|
|
|
@ -969,13 +969,13 @@ static ThrowCompletionOr<Value> create_html(GlobalObject& global_object, Value s
|
|||
auto value_string = TRY(value.to_string(global_object));
|
||||
builder.append(' ');
|
||||
builder.append(attribute);
|
||||
builder.append("=\"");
|
||||
builder.append(value_string.replace("\"", """, ReplaceMode::All));
|
||||
builder.append("=\""sv);
|
||||
builder.append(value_string.replace("\""sv, """sv, ReplaceMode::All));
|
||||
builder.append('"');
|
||||
}
|
||||
builder.append('>');
|
||||
builder.append(str);
|
||||
builder.append("</");
|
||||
builder.append("</"sv);
|
||||
builder.append(tag);
|
||||
builder.append('>');
|
||||
return js_string(vm, builder.build());
|
||||
|
|
|
@ -449,7 +449,7 @@ void TypedArrayBase::visit_edges(Visitor& visitor)
|
|||
: TypedArray(prototype, \
|
||||
reinterpret_cast<TypedArrayBase::IntrinsicConstructor>(&GlobalObject::snake_name##_constructor), length, array_buffer) \
|
||||
{ \
|
||||
if constexpr (StringView { #ClassName }.is_one_of("BigInt64Array", "BigUint64Array")) \
|
||||
if constexpr (#ClassName##sv.is_one_of("BigInt64Array", "BigUint64Array")) \
|
||||
m_content_type = ContentType::BigInt; \
|
||||
else \
|
||||
m_content_type = ContentType::Number; \
|
||||
|
|
|
@ -599,7 +599,7 @@ String VM::join_arguments(size_t start_index) const
|
|||
{
|
||||
StringBuilder joined_arguments;
|
||||
for (size_t i = start_index; i < argument_count(); ++i) {
|
||||
joined_arguments.append(argument(i).to_string_without_side_effects().characters());
|
||||
joined_arguments.append(argument(i).to_string_without_side_effects().view());
|
||||
if (i != argument_count() - 1)
|
||||
joined_arguments.append(' ');
|
||||
}
|
||||
|
|
|
@ -156,7 +156,7 @@ static String double_to_string(double d)
|
|||
return builder.to_string();
|
||||
}
|
||||
if (-6 < exponent && exponent <= 0) {
|
||||
builder.append("0.");
|
||||
builder.append("0."sv);
|
||||
builder.append(String::repeated('0', -exponent));
|
||||
builder.append(digits);
|
||||
return builder.to_string();
|
||||
|
|
|
@ -205,7 +205,7 @@ String Token::string_value(StringValueStatus& status) const
|
|||
}
|
||||
|
||||
lexer.retreat();
|
||||
builder.append(lexer.consume_escaped_character('\\', "b\bf\fn\nr\rt\tv\v"));
|
||||
builder.append(lexer.consume_escaped_character('\\', "b\bf\fn\nr\rt\tv\v"sv));
|
||||
}
|
||||
return builder.to_string();
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ String Token::string_value(StringValueStatus& status) const
|
|||
// 12.8.6.2 Static Semantics: TRV, https://tc39.es/ecma262/#sec-static-semantics-trv
|
||||
String Token::raw_template_value() const
|
||||
{
|
||||
return value().replace("\r\n", "\n", ReplaceMode::All).replace("\r", "\n", ReplaceMode::All);
|
||||
return value().replace("\r\n"sv, "\n"sv, ReplaceMode::All).replace("\r"sv, "\n"sv, ReplaceMode::All);
|
||||
}
|
||||
|
||||
bool Token::bool_value() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue