1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 09:24:57 +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

@ -105,26 +105,26 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<JsonValue> sorted_regions = json.as_array().values();
quick_sort(sorted_regions, [](auto& a, auto& b) {
return a.as_object().get("ip_address").to_string() < b.as_object().get("ip_address").to_string();
return a.as_object().get("ip_address"sv).to_string() < b.as_object().get("ip_address"sv).to_string();
});
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
auto ip_address = if_object.get("ip_address").to_string();
auto ip_address = if_object.get("ip_address"sv).to_string();
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(ip_address);
auto addr = from_string.value().to_in_addr_t();
auto* hostent = gethostbyaddr(&addr, sizeof(in_addr), AF_INET);
if (hostent != nullptr) {
auto host_name = StringView(hostent->h_name);
StringView host_name { hostent->h_name, strlen(hostent->h_name) };
if (!host_name.is_empty())
ip_address = host_name;
}
}
auto mac_address = if_object.get("mac_address").to_string();
auto mac_address = if_object.get("mac_address"sv).to_string();
if (proto_address_column != -1)
columns[proto_address_column].buffer = ip_address;