summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS
diff options
context:
space:
mode:
authorsin-ack <sin-ack@users.noreply.github.com>2022-07-11 17:32:29 +0000
committerAndreas Kling <kling@serenityos.org>2022-07-12 23:11:35 +0200
commit3f3f45580ab7266258e97cb3cecf1e24716d61c5 (patch)
tree152c7a187c98184d58bf91a326357e0af435edcf /Userland/Libraries/LibJS
parente5f09ea1703bacfbb79a4ad3c587a7d5d3d7bb13 (diff)
downloadserenity-3f3f45580ab7266258e97cb3cecf1e24716d61c5.zip
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.
Diffstat (limited to 'Userland/Libraries/LibJS')
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Label.h2
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Op.cpp14
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp2
-rw-r--r--Userland/Libraries/LibJS/Bytecode/Register.h4
-rw-r--r--Userland/Libraries/LibJS/Console.cpp8
-rw-r--r--Userland/Libraries/LibJS/CyclicModule.cpp6
-rw-r--r--Userland/Libraries/LibJS/Lexer.cpp2
-rw-r--r--Userland/Libraries/LibJS/Lexer.h2
-rw-r--r--Userland/Libraries/LibJS/MarkupGenerator.cpp4
-rw-r--r--Userland/Libraries/LibJS/Parser.cpp12
-rw-r--r--Userland/Libraries/LibJS/Parser.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/DateConstructor.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Environment.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp4
-rw-r--r--Userland/Libraries/LibJS/Runtime/JSONObject.cpp22
-rw-r--r--Userland/Libraries/LibJS/Runtime/Object.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PropertyAttributes.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Reference.cpp14
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpObject.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/StringPrototype.cpp6
-rw-r--r--Userland/Libraries/LibJS/Runtime/TypedArray.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/VM.cpp2
-rw-r--r--Userland/Libraries/LibJS/Runtime/Value.cpp2
-rw-r--r--Userland/Libraries/LibJS/Token.cpp4
26 files changed, 64 insertions, 64 deletions
diff --git a/Userland/Libraries/LibJS/Bytecode/Label.h b/Userland/Libraries/LibJS/Bytecode/Label.h
index a858ef0fc0..44698f6704 100644
--- a/Userland/Libraries/LibJS/Bytecode/Label.h
+++ b/Userland/Libraries/LibJS/Bytecode/Label.h
@@ -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());
}
};
diff --git a/Userland/Libraries/LibJS/Bytecode/Op.cpp b/Userland/Libraries/LibJS/Bytecode/Op.cpp
index 6b12f737a5..62a9c2cd0b 100644
--- a/Userland/Libraries/LibJS/Bytecode/Op.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Op.cpp
@@ -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();
}
diff --git a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
index e80d7f7029..f9e3ac55bd 100644
--- a/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
+++ b/Userland/Libraries/LibJS/Bytecode/Pass/MergeBlocks.cpp
@@ -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('.');
diff --git a/Userland/Libraries/LibJS/Bytecode/Register.h b/Userland/Libraries/LibJS/Bytecode/Register.h
index aeae630f3d..1bdab0eeb7 100644
--- a/Userland/Libraries/LibJS/Bytecode/Register.h
+++ b/Userland/Libraries/LibJS/Bytecode/Register.h
@@ -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());
}
};
diff --git a/Userland/Libraries/LibJS/Console.cpp b/Userland/Libraries/LibJS/Console.cpp
index 956dc0c5c0..2d2bfadf79 100644
--- a/Userland/Libraries/LibJS/Console.cpp
+++ b/Userland/Libraries/LibJS/Console.cpp
@@ -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();
diff --git a/Userland/Libraries/LibJS/CyclicModule.cpp b/Userland/Libraries/LibJS/CyclicModule.cpp
index 7320477782..55515c16e0 100644
--- a/Userland/Libraries/LibJS/CyclicModule.cpp
+++ b/Userland/Libraries/LibJS/CyclicModule.cpp
@@ -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
diff --git a/Userland/Libraries/LibJS/Lexer.cpp b/Userland/Libraries/LibJS/Lexer.cpp
index 23a8e2de64..d7b24d9bfb 100644
--- a/Userland/Libraries/LibJS/Lexer.cpp
+++ b/Userland/Libraries/LibJS/Lexer.cpp
@@ -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,
diff --git a/Userland/Libraries/LibJS/Lexer.h b/Userland/Libraries/LibJS/Lexer.h
index 326f5aa45b..3cb25f68db 100644
--- a/Userland/Libraries/LibJS/Lexer.h
+++ b/Userland/Libraries/LibJS/Lexer.h
@@ -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();
diff --git a/Userland/Libraries/LibJS/MarkupGenerator.cpp b/Userland/Libraries/LibJS/MarkupGenerator.cpp
index eae5ad4c80..995d72ce10 100644
--- a/Userland/Libraries/LibJS/MarkupGenerator.cpp
+++ b/Userland/Libraries/LibJS/MarkupGenerator.cpp
@@ -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("&lt;empty&gt;");
+ output_html.append("&lt;empty&gt;"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)
diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp
index 867cc79c3f..48dc4c4c85 100644
--- a/Userland/Libraries/LibJS/Parser.cpp
+++ b/Userland/Libraries/LibJS/Parser.cpp
@@ -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;
}
diff --git a/Userland/Libraries/LibJS/Parser.h b/Userland/Libraries/LibJS/Parser.h
index d1f0ba0235..ffbe199e9c 100644
--- a/Userland/Libraries/LibJS/Parser.h
+++ b/Userland/Libraries/LibJS/Parser.h
@@ -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');
diff --git a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
index f375e7b975..2527cd74f2 100644
--- a/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
+++ b/Userland/Libraries/LibJS/Runtime/DateConstructor.cpp
@@ -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();
diff --git a/Userland/Libraries/LibJS/Runtime/Environment.h b/Userland/Libraries/LibJS/Runtime/Environment.h
index 62b0618a76..3fbc9643c3 100644
--- a/Userland/Libraries/LibJS/Runtime/Environment.h
+++ b/Userland/Libraries/LibJS/Runtime/Environment.h
@@ -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:
diff --git a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
index bb676f29f9..1989731a62 100644
--- a/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Intl/DurationFormat.cpp
@@ -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 });
}
}
diff --git a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
index 36a30160aa..3eb4d9f21f 100644
--- a/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/JSONObject.cpp
@@ -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)) {
diff --git a/Userland/Libraries/LibJS/Runtime/Object.h b/Userland/Libraries/LibJS/Runtime/Object.h
index 6876bd8d1a..e77fda9c17 100644
--- a/Userland/Libraries/LibJS/Runtime/Object.h
+++ b/Userland/Libraries/LibJS/Runtime/Object.h
@@ -30,7 +30,7 @@ public: \
using Base = base_class; \
virtual StringView class_name() const override \
{ \
- return #class_; \
+ return #class_##sv; \
}
struct PrivateElement {
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h
index 1c558e67ff..6713ab079d 100644
--- a/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h
+++ b/Userland/Libraries/LibJS/Runtime/PropertyAttributes.h
@@ -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)));
}
};
diff --git a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h
index 2fd209147d..048ef7cd99 100644
--- a/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h
+++ b/Userland/Libraries/LibJS/Runtime/PropertyDescriptor.h
@@ -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)));
}
};
diff --git a/Userland/Libraries/LibJS/Runtime/Reference.cpp b/Userland/Libraries/LibJS/Runtime/Reference.cpp
index 1c31fd5cd6..c433c51c93 100644
--- a/Userland/Libraries/LibJS/Runtime/Reference.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Reference.cpp
@@ -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();
}
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
index cfbfbc3063..7a011a09c1 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpObject.cpp
@@ -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
diff --git a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
index 9b898ed46c..608e318cdd 100644
--- a/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/RegExpPrototype.cpp
@@ -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
diff --git a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
index 7484610a63..8ffc5403f6 100644
--- a/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
+++ b/Userland/Libraries/LibJS/Runtime/StringPrototype.cpp
@@ -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("\"", "&quot;", ReplaceMode::All));
+ builder.append("=\""sv);
+ builder.append(value_string.replace("\""sv, "&quot;"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());
diff --git a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
index 22e22da0db..96a33aef50 100644
--- a/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
+++ b/Userland/Libraries/LibJS/Runtime/TypedArray.cpp
@@ -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; \
diff --git a/Userland/Libraries/LibJS/Runtime/VM.cpp b/Userland/Libraries/LibJS/Runtime/VM.cpp
index 193c01d25f..a7a12df189 100644
--- a/Userland/Libraries/LibJS/Runtime/VM.cpp
+++ b/Userland/Libraries/LibJS/Runtime/VM.cpp
@@ -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(' ');
}
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp
index 66838574e5..c560763156 100644
--- a/Userland/Libraries/LibJS/Runtime/Value.cpp
+++ b/Userland/Libraries/LibJS/Runtime/Value.cpp
@@ -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();
diff --git a/Userland/Libraries/LibJS/Token.cpp b/Userland/Libraries/LibJS/Token.cpp
index cca3375778..496761937f 100644
--- a/Userland/Libraries/LibJS/Token.cpp
+++ b/Userland/Libraries/LibJS/Token.cpp
@@ -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