1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:37: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:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -987,16 +987,16 @@ bool Node::is_uninteresting_whitespace_node() const
void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) const
{
MUST(object.add("name", node_name().view()));
MUST(object.add("id", id()));
MUST(object.add("name"sv, node_name().view()));
MUST(object.add("id"sv, id()));
if (is_document()) {
MUST(object.add("type", "document"));
MUST(object.add("type"sv, "document"));
} else if (is_element()) {
MUST(object.add("type", "element"));
MUST(object.add("type"sv, "element"));
auto const* element = static_cast<DOM::Element const*>(this);
if (element->has_attributes()) {
auto attributes = MUST(object.add_object("attributes"));
auto attributes = MUST(object.add_object("attributes"sv));
element->for_each_attribute([&attributes](auto& name, auto& value) {
MUST(attributes.add(name, value));
});
@ -1006,7 +1006,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
if (element->is_browsing_context_container()) {
auto const* container = static_cast<HTML::BrowsingContextContainer const*>(element);
if (auto const* content_document = container->content_document()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
JsonObjectSerializer<StringBuilder> content_document_object = MUST(children.add_object());
content_document->serialize_tree_as_json(content_document_object);
MUST(content_document_object.finish());
@ -1014,10 +1014,10 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
}
}
} else if (is_text()) {
MUST(object.add("type", "text"));
MUST(object.add("type"sv, "text"));
auto text_node = static_cast<DOM::Text const*>(this);
MUST(object.add("text", text_node->data()));
MUST(object.add("text"sv, text_node->data()));
} else if (is_comment()) {
MUST(object.add("type"sv, "comment"sv));
MUST(object.add("data"sv, static_cast<DOM::Comment const&>(*this).data()));
@ -1026,7 +1026,7 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
MUST((object.add("visible"sv, !!layout_node())));
if (has_child_nodes()) {
auto children = MUST(object.add_array("children"));
auto children = MUST(object.add_array("children"sv));
for_each_child([&children](DOM::Node& child) {
if (child.is_uninteresting_whitespace_node())
return;