diff --git a/AK/DateConstants.h b/AK/DateConstants.h index 9bf3828f238..e1de17e7640 100644 --- a/AK/DateConstants.h +++ b/AK/DateConstants.h @@ -12,29 +12,29 @@ namespace AK { static constexpr Array long_day_names = { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" + "Sunday"sv, "Monday"sv, "Tuesday"sv, "Wednesday"sv, "Thursday"sv, "Friday"sv, "Saturday"sv }; static constexpr Array short_day_names = { - "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" + "Sun"sv, "Mon"sv, "Tue"sv, "Wed"sv, "Thu"sv, "Fri"sv, "Sat"sv }; static constexpr Array mini_day_names = { - "Su", "Mo", "Tu", "We", "Th", "Fr", "Sa" + "Su"sv, "Mo"sv, "Tu"sv, "We"sv, "Th"sv, "Fr"sv, "Sa"sv }; static constexpr Array micro_day_names = { - "S", "M", "T", "W", "T", "F", "S" + "S"sv, "M"sv, "T"sv, "W"sv, "T"sv, "F"sv, "S"sv }; static constexpr Array long_month_names = { - "January", "February", "March", "April", "May", "June", - "July", "August", "September", "October", "November", "December" + "January"sv, "February"sv, "March"sv, "April"sv, "May"sv, "June"sv, + "July"sv, "August"sv, "September"sv, "October"sv, "November"sv, "December"sv }; static constexpr Array short_month_names = { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" + "Jan"sv, "Feb"sv, "Mar"sv, "Apr"sv, "May"sv, "Jun"sv, + "Jul"sv, "Aug"sv, "Sep"sv, "Oct"sv, "Nov"sv, "Dec"sv }; } diff --git a/AK/Format.cpp b/AK/Format.cpp index cad570e6b48..ee68a18f519 100644 --- a/AK/Format.cpp +++ b/AK/Format.cpp @@ -114,7 +114,7 @@ StringView FormatParser::consume_literal() if (consume_specific("}}")) continue; - if (next_is(is_any_of("{}"))) + if (next_is(is_any_of("{}"sv))) return m_input.substring_view(begin, tell() - begin); consume(); @@ -170,7 +170,7 @@ bool FormatParser::consume_specifier(FormatSpecifier& specifier) if (!consume_specific('}')) VERIFY_NOT_REACHED(); - specifier.flags = ""; + specifier.flags = ""sv; } return true; @@ -287,16 +287,16 @@ ErrorOr FormatBuilder::put_u64( if (prefix) { if (base == 2) { if (upper_case) - TRY(m_builder.try_append("0B")); + TRY(m_builder.try_append("0B"sv)); else - TRY(m_builder.try_append("0b")); + TRY(m_builder.try_append("0b"sv)); } else if (base == 8) { - TRY(m_builder.try_append("0")); + TRY(m_builder.try_append("0"sv)); } else if (base == 16) { if (upper_case) - TRY(m_builder.try_append("0X")); + TRY(m_builder.try_append("0X"sv)); else - TRY(m_builder.try_append("0x")); + TRY(m_builder.try_append("0x"sv)); } } return {}; @@ -587,8 +587,8 @@ ErrorOr vformat(StringBuilder& builder, StringView fmtstr, TypeErasedForma void StandardFormatter::parse(TypeErasedFormatParams& params, FormatParser& parser) { - if (StringView { "<^>" }.contains(parser.peek(1))) { - VERIFY(!parser.next_is(is_any_of("{}"))); + if ("<^>"sv.contains(parser.peek(1))) { + VERIFY(!parser.next_is(is_any_of("{}"sv))); m_fill = parser.consume(); } @@ -788,7 +788,7 @@ ErrorOr Formatter::format(FormatBuilder& builder, bool value) return builder.put_hexdump({ &value, sizeof(value) }, m_width.value_or(32), m_fill); } else { Formatter formatter { *this }; - return formatter.format(builder, value ? "true" : "false"); + return formatter.format(builder, value ? "true"sv : "false"sv); } } #ifndef KERNEL diff --git a/AK/Format.h b/AK/Format.h index b9b69ca15bf..d89699bde5e 100644 --- a/AK/Format.h +++ b/AK/Format.h @@ -638,7 +638,7 @@ template struct __FormatIfSupported : Formatter { ErrorOr format(FormatBuilder& builder, FormatIfSupported const&) { - return Formatter::format(builder, "?"); + return Formatter::format(builder, "?"sv); } }; template @@ -673,15 +673,15 @@ struct Formatter : Formatter { { #if defined(__serenity__) && defined(KERNEL) if (error.is_errno()) - return Formatter::format(builder, "Error(errno={})", error.code()); - return Formatter::format(builder, "Error({})", error.string_literal()); + return Formatter::format(builder, "Error(errno={})"sv, error.code()); + return Formatter::format(builder, "Error({})"sv, error.string_literal()); #else if (error.is_syscall()) - return Formatter::format(builder, "{}: {} (errno={})", error.string_literal(), strerror(error.code()), error.code()); + return Formatter::format(builder, "{}: {} (errno={})"sv, error.string_literal(), strerror(error.code()), error.code()); if (error.is_errno()) - return Formatter::format(builder, "{} (errno={})", strerror(error.code()), error.code()); + return Formatter::format(builder, "{} (errno={})"sv, strerror(error.code()), error.code()); - return Formatter::format(builder, "{}", error.string_literal()); + return Formatter::format(builder, "{}"sv, error.string_literal()); #endif } }; @@ -691,8 +691,8 @@ struct Formatter> : Formatter { ErrorOr format(FormatBuilder& builder, ErrorOr const& error_or) { if (error_or.is_error()) - return Formatter::format(builder, "{}", error_or.error()); - return Formatter::format(builder, "{{{}}}", error_or.value()); + return Formatter::format(builder, "{}"sv, error_or.error()); + return Formatter::format(builder, "{{{}}}"sv, error_or.value()); } }; diff --git a/AK/GenericLexer.h b/AK/GenericLexer.h index f5d5396ac4c..b7f2765c446 100644 --- a/AK/GenericLexer.h +++ b/AK/GenericLexer.h @@ -95,7 +95,7 @@ public: return consume_specific(StringView { next, __builtin_strlen(next) }); } - constexpr char consume_escaped_character(char escape_char = '\\', StringView escape_map = "n\nr\rt\tb\bf\f") + constexpr char consume_escaped_character(char escape_char = '\\', StringView escape_map = "n\nr\rt\tb\bf\f"sv) { if (!consume_specific(escape_char)) return consume(); @@ -234,8 +234,8 @@ constexpr auto is_not_any_of(StringView values) return [values](auto c) { return !values.contains(c); }; } -constexpr auto is_path_separator = is_any_of("/\\"); -constexpr auto is_quote = is_any_of("'\""); +constexpr auto is_path_separator = is_any_of("/\\"sv); +constexpr auto is_quote = is_any_of("'\""sv); } diff --git a/AK/JsonObject.h b/AK/JsonObject.h index 469ac97e442..0dee35718dd 100644 --- a/AK/JsonObject.h +++ b/AK/JsonObject.h @@ -193,7 +193,7 @@ inline void JsonValue::serialize(Builder& builder) const m_value.as_object->serialize(builder); break; case Type::Bool: - builder.append(m_value.as_bool ? "true" : "false"); + builder.append(m_value.as_bool ? "true"sv : "false"sv); break; #if !defined(KERNEL) case Type::Double: @@ -213,7 +213,7 @@ inline void JsonValue::serialize(Builder& builder) const builder.appendff("{}", as_u64()); break; case Type::Null: - builder.append("null"); + builder.append("null"sv); break; default: VERIFY_NOT_REACHED(); diff --git a/AK/JsonObjectSerializer.h b/AK/JsonObjectSerializer.h index b13b45985b7..2a8a2ab1b53 100644 --- a/AK/JsonObjectSerializer.h +++ b/AK/JsonObjectSerializer.h @@ -103,9 +103,9 @@ public: { TRY(begin_item(key)); if constexpr (IsLegacyBuilder) - TRY(m_builder.try_append(value ? "true" : "false")); + TRY(m_builder.try_append(value ? "true"sv : "false"sv)); else - TRY(m_builder.append(value ? "true" : "false")); + TRY(m_builder.append(value ? "true"sv : "false"sv)); return {}; } @@ -234,11 +234,11 @@ private: if constexpr (IsLegacyBuilder) { TRY(m_builder.try_append('"')); TRY(m_builder.try_append_escaped_for_json(key)); - TRY(m_builder.try_append("\":")); + TRY(m_builder.try_append("\":"sv)); } else { TRY(m_builder.append('"')); TRY(m_builder.append_escaped_for_json(key)); - TRY(m_builder.append("\":")); + TRY(m_builder.append("\":"sv)); } return {}; } diff --git a/AK/JsonPath.cpp b/AK/JsonPath.cpp index 9ad66184744..6a9f2dad370 100644 --- a/AK/JsonPath.cpp +++ b/AK/JsonPath.cpp @@ -34,12 +34,12 @@ JsonValue JsonPath::resolve(JsonValue const& top_root) const String JsonPath::to_string() const { StringBuilder builder; - builder.append("{ ."); + builder.append("{ ."sv); for (auto const& el : *this) { - builder.append(" > "); + builder.append("sv > "sv); builder.append(el.to_string()); } - builder.append(" }"); + builder.append("sv }"sv); return builder.to_string(); } diff --git a/AK/LexicalPath.cpp b/AK/LexicalPath.cpp index a80d11236d8..ed7c10c2dc8 100644 --- a/AK/LexicalPath.cpp +++ b/AK/LexicalPath.cpp @@ -133,7 +133,7 @@ String LexicalPath::relative_path(StringView a_path, StringView a_prefix) { if (!a_path.starts_with('/') || !a_prefix.starts_with('/')) { // FIXME: This should probably VERIFY or return an Optional. - return {}; + return ""sv; } if (a_path == a_prefix) @@ -171,7 +171,7 @@ LexicalPath LexicalPath::prepend(StringView value) const LexicalPath LexicalPath::parent() const { - return append(".."); + return append(".."sv); } } diff --git a/AK/SourceLocation.h b/AK/SourceLocation.h index a25f661a13a..21c7eff905d 100644 --- a/AK/SourceLocation.h +++ b/AK/SourceLocation.h @@ -45,7 +45,7 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, AK::SourceLocation location) { - return AK::Formatter::format(builder, "[\x1b[34m{}\x1b[0m @ {}:{}]", location.function_name(), location.filename(), location.line_number()); + return AK::Formatter::format(builder, "[\x1b[34m{}\x1b[0m @ {}:{}]"sv, location.function_name(), location.filename(), location.line_number()); } }; diff --git a/AK/String.cpp b/AK/String.cpp index a74dec2c41c..a3cadadb71a 100644 --- a/AK/String.cpp +++ b/AK/String.cpp @@ -346,13 +346,13 @@ String escape_html_entities(StringView html) StringBuilder builder; for (size_t i = 0; i < html.length(); ++i) { if (html[i] == '<') - builder.append("<"); + builder.append("<"sv); else if (html[i] == '>') - builder.append(">"); + builder.append(">"sv); else if (html[i] == '&') - builder.append("&"); + builder.append("&"sv); else if (html[i] == '"') - builder.append("""); + builder.append("""sv); else builder.append(html[i]); } diff --git a/AK/StringBuilder.cpp b/AK/StringBuilder.cpp index 58460911f79..52ba4ffda72 100644 --- a/AK/StringBuilder.cpp +++ b/AK/StringBuilder.cpp @@ -180,19 +180,19 @@ ErrorOr StringBuilder::try_append_escaped_for_json(StringView string) for (auto ch : string) { switch (ch) { case '\b': - TRY(try_append("\\b")); + TRY(try_append("\\b"sv)); break; case '\n': - TRY(try_append("\\n")); + TRY(try_append("\\n"sv)); break; case '\t': - TRY(try_append("\\t")); + TRY(try_append("\\t"sv)); break; case '\"': - TRY(try_append("\\\"")); + TRY(try_append("\\\""sv)); break; case '\\': - TRY(try_append("\\\\")); + TRY(try_append("\\\\"sv)); break; default: if (ch >= 0 && ch <= 0x1f) diff --git a/AK/StringUtils.cpp b/AK/StringUtils.cpp index 21ddbb7ad8d..bc2ae22e7a4 100644 --- a/AK/StringUtils.cpp +++ b/AK/StringUtils.cpp @@ -329,7 +329,7 @@ StringView trim(StringView str, StringView characters, TrimMode mode) if (mode == TrimMode::Left || mode == TrimMode::Both) { for (size_t i = 0; i < str.length(); ++i) { if (substring_length == 0) - return ""; + return ""sv; if (!characters.contains(str[i])) break; ++substring_start; @@ -340,7 +340,7 @@ StringView trim(StringView str, StringView characters, TrimMode mode) if (mode == TrimMode::Right || mode == TrimMode::Both) { for (size_t i = str.length() - 1; i > 0; --i) { if (substring_length == 0) - return ""; + return ""sv; if (!characters.contains(str[i])) break; --substring_length; @@ -352,7 +352,7 @@ StringView trim(StringView str, StringView characters, TrimMode mode) StringView trim_whitespace(StringView str, TrimMode mode) { - return trim(str, " \n\t\v\f\r", mode); + return trim(str, " \n\t\v\f\r"sv, mode); } Optional find(StringView haystack, char needle, size_t start) diff --git a/AK/URL.cpp b/AK/URL.cpp index 3b1744fd786..3cb00c9ffd6 100644 --- a/AK/URL.cpp +++ b/AK/URL.cpp @@ -221,7 +221,7 @@ String URL::serialize_data_url() const builder.append(':'); builder.append(m_data_mime_type); if (m_data_payload_is_base64) - builder.append(";base64"); + builder.append(";base64"sv); builder.append(','); // NOTE: The specification does not say anything about encoding this, but we should encode at least control and non-ASCII // characters (since this is also a valid representation of the same data URL). @@ -239,7 +239,7 @@ String URL::serialize(ExcludeFragment exclude_fragment) const builder.append(':'); if (!m_host.is_null()) { - builder.append("//"); + builder.append("//"sv); if (includes_credentials()) { builder.append(percent_encode(m_username, PercentEncodeSet::Userinfo)); @@ -259,7 +259,7 @@ String URL::serialize(ExcludeFragment exclude_fragment) const builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path)); } else { if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty()) - builder.append("/."); + builder.append("/."sv); for (auto& segment : m_paths) { builder.append('/'); builder.append(percent_encode(segment, PercentEncodeSet::Path)); @@ -293,7 +293,7 @@ String URL::serialize_for_display() const builder.append(':'); if (!m_host.is_null()) { - builder.append("//"); + builder.append("//"sv); builder.append(m_host); if (m_port.has_value()) builder.appendff(":{}", *m_port); @@ -303,7 +303,7 @@ String URL::serialize_for_display() const builder.append(percent_encode(m_paths[0], PercentEncodeSet::Path)); } else { if (m_host.is_null() && m_paths.size() > 1 && m_paths[0].is_empty()) - builder.append("/."); + builder.append("/."sv); for (auto& segment : m_paths) { builder.append('/'); builder.append(percent_encode(segment, PercentEncodeSet::Path)); diff --git a/AK/URLParser.cpp b/AK/URLParser.cpp index 0d5b7476df8..98f218a2ea5 100644 --- a/AK/URLParser.cpp +++ b/AK/URLParser.cpp @@ -155,18 +155,18 @@ static String percent_encode_after_encoding(StringView input, URL::PercentEncode Optional URLParser::parse_data_url(StringView raw_input) { dbgln_if(URL_PARSER_DEBUG, "URLParser::parse_data_url: Parsing '{}'.", raw_input); - VERIFY(raw_input.starts_with("data:")); + VERIFY(raw_input.starts_with("data:"sv)); auto input = raw_input.substring_view(5); auto comma_offset = input.find(','); if (!comma_offset.has_value()) return {}; - auto mime_type = StringUtils::trim(input.substring_view(0, comma_offset.value()), "\t\n\f\r ", TrimMode::Both); + auto mime_type = StringUtils::trim(input.substring_view(0, comma_offset.value()), "\t\n\f\r "sv, TrimMode::Both); auto encoded_body = input.substring_view(comma_offset.value() + 1); auto body = URL::percent_decode(encoded_body); bool is_base64_encoded = false; - if (mime_type.ends_with("base64", CaseSensitivity::CaseInsensitive)) { + if (mime_type.ends_with("base64"sv, CaseSensitivity::CaseInsensitive)) { auto substring_view = mime_type.substring_view(0, mime_type.length() - 6); - auto trimmed_substring_view = StringUtils::trim(substring_view, " ", TrimMode::Right); + auto trimmed_substring_view = StringUtils::trim(substring_view, " "sv, TrimMode::Right); if (trimmed_substring_view.ends_with(';')) { is_base64_encoded = true; mime_type = trimmed_substring_view.substring_view(0, trimmed_substring_view.length() - 1); @@ -174,14 +174,14 @@ Optional URLParser::parse_data_url(StringView raw_input) } StringBuilder builder; - if (mime_type.starts_with(";") || mime_type.is_empty()) { - builder.append("text/plain"); + if (mime_type.starts_with(";"sv) || mime_type.is_empty()) { + builder.append("text/plain"sv); builder.append(mime_type); mime_type = builder.string_view(); } // FIXME: Parse the MIME type's components according to https://mimesniff.spec.whatwg.org/#parse-a-mime-type - URL url { StringUtils::trim(mime_type, "\n\r\t ", TrimMode::Both), move(body), is_base64_encoded }; + URL url { StringUtils::trim(mime_type, "\n\r\t "sv, TrimMode::Both), move(body), is_base64_encoded }; dbgln_if(URL_PARSER_DEBUG, "URLParser::parse_data_url: Parsed data URL to be '{}'.", url.serialize()); return url; } @@ -202,7 +202,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur if (raw_input.is_empty()) return {}; - if (raw_input.starts_with("data:")) { + if (raw_input.starts_with("data:"sv)) { auto maybe_url = parse_data_url(raw_input); if (!maybe_url.has_value()) return {}; @@ -243,9 +243,9 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur String processed_input = raw_input.substring_view(start_index, end_index - start_index); // NOTE: This replaces all tab and newline characters with nothing. - if (processed_input.contains("\t") || processed_input.contains("\n")) { + if (processed_input.contains("\t"sv) || processed_input.contains("\n"sv)) { report_validation_error(); - processed_input = processed_input.replace("\t", "", ReplaceMode::All).replace("\n", "", ReplaceMode::All); + processed_input = processed_input.replace("\t"sv, ""sv, ReplaceMode::All).replace("\n"sv, ""sv, ReplaceMode::All); } State state = state_override.value_or(State::SchemeStart); @@ -295,7 +295,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur url->m_scheme = buffer.to_string(); buffer.clear(); if (url->scheme() == "file") { - if (!get_remaining().starts_with("//")) { + if (!get_remaining().starts_with("//"sv)) { report_validation_error(); } state = State::File; @@ -304,7 +304,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur state = State::SpecialRelativeOrAuthority; else state = State::SpecialAuthoritySlashes; - } else if (get_remaining().starts_with("/")) { + } else if (get_remaining().starts_with("/"sv)) { state = State::PathOrAuthority; ++iterator; } else { @@ -339,7 +339,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur } break; case State::SpecialRelativeOrAuthority: - if (code_point == '/' && get_remaining().starts_with("/")) { + if (code_point == '/' && get_remaining().starts_with("/"sv)) { state = State::SpecialAuthorityIgnoreSlashes; ++iterator; } else { @@ -403,7 +403,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur } break; case State::SpecialAuthoritySlashes: - if (code_point == '/' && get_remaining().starts_with("/")) { + if (code_point == '/' && get_remaining().starts_with("/"sv)) { state = State::SpecialAuthorityIgnoreSlashes; ++iterator; } else { @@ -426,7 +426,7 @@ URL URLParser::parse(StringView raw_input, URL const* base_url, Optional ur if (at_sign_seen) { auto content = buffer.to_string(); buffer.clear(); - buffer.append("%40"); + buffer.append("%40"sv); buffer.append(content); } at_sign_seen = true; diff --git a/Kernel/Arch/x86/IO.h b/Kernel/Arch/x86/IO.h index f38dfc89bd2..79a7b92a4c8 100644 --- a/Kernel/Arch/x86/IO.h +++ b/Kernel/Arch/x86/IO.h @@ -148,6 +148,6 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, IOAddress value) { - return Formatter::format(builder, "IO {:x}", value.get()); + return Formatter::format(builder, "IO {:x}"sv, value.get()); } }; diff --git a/Kernel/Arch/x86/ProcessorInfo.h b/Kernel/Arch/x86/ProcessorInfo.h index c417fd6ac4f..6bb90b0ea71 100644 --- a/Kernel/Arch/x86/ProcessorInfo.h +++ b/Kernel/Arch/x86/ProcessorInfo.h @@ -42,8 +42,8 @@ public: void set_apic_id(u32 apic_id) { m_apic_id = apic_id; } - static constexpr StringView s_amd_vendor_id = "AuthenticAMD"; - static constexpr StringView s_intel_vendor_id = "GenuineIntel"; + static constexpr StringView s_amd_vendor_id = "AuthenticAMD"sv; + static constexpr StringView s_intel_vendor_id = "GenuineIntel"sv; private: static NonnullOwnPtr build_vendor_id_string(); diff --git a/Kernel/Arch/x86/common/InterruptManagement.cpp b/Kernel/Arch/x86/common/InterruptManagement.cpp index 08174be0ec8..5a137c38e1c 100644 --- a/Kernel/Arch/x86/common/InterruptManagement.cpp +++ b/Kernel/Arch/x86/common/InterruptManagement.cpp @@ -126,7 +126,7 @@ UNMAP_AFTER_INIT PhysicalAddress InterruptManagement::search_for_madt() auto rsdp = ACPI::StaticParsing::find_rsdp(); if (!rsdp.has_value()) return {}; - auto apic = ACPI::StaticParsing::find_table(rsdp.value(), "APIC"); + auto apic = ACPI::StaticParsing::find_table(rsdp.value(), "APIC"sv); if (!apic.has_value()) return {}; return apic.value(); diff --git a/Kernel/Bus/PCI/Access.cpp b/Kernel/Bus/PCI/Access.cpp index cc0886aa185..c8c7af840d4 100644 --- a/Kernel/Bus/PCI/Access.cpp +++ b/Kernel/Bus/PCI/Access.cpp @@ -74,7 +74,7 @@ UNMAP_AFTER_INIT bool Access::find_and_register_pci_host_bridges_from_acpi_mcfg_ dbgln("Failed to round up length of {} to pages", length); return false; } - auto mcfg_region_or_error = MM.allocate_kernel_region(mcfg_table.page_base(), region_size_or_error.value(), "PCI Parsing MCFG", Memory::Region::Access::ReadWrite); + auto mcfg_region_or_error = MM.allocate_kernel_region(mcfg_table.page_base(), region_size_or_error.value(), "PCI Parsing MCFG"sv, Memory::Region::Access::ReadWrite); if (mcfg_region_or_error.is_error()) return false; auto& mcfg = *(ACPI::Structures::MCFG*)mcfg_region_or_error.value()->vaddr().offset(mcfg_table.offset_in_page()).as_ptr(); diff --git a/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp b/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp index 4cfb1663819..41bb7991df7 100644 --- a/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp +++ b/Kernel/Bus/PCI/Controller/MemoryBackedHostBridge.cpp @@ -69,7 +69,7 @@ void MemoryBackedHostBridge::map_bus_region(BusNumber bus) if (m_mapped_bus == bus && m_mapped_bus_region) return; auto bus_base_address = determine_memory_mapped_bus_base_address(bus); - auto region_or_error = MM.allocate_kernel_region(bus_base_address, memory_range_per_bus, "PCI ECAM", Memory::Region::Access::ReadWrite); + auto region_or_error = MM.allocate_kernel_region(bus_base_address, memory_range_per_bus, "PCI ECAM"sv, Memory::Region::Access::ReadWrite); // FIXME: Find a way to propagate error from here. if (region_or_error.is_error()) VERIFY_NOT_REACHED(); diff --git a/Kernel/Bus/PCI/Definitions.h b/Kernel/Bus/PCI/Definitions.h index e2b4c3a3cad..96b72b6de85 100644 --- a/Kernel/Bus/PCI/Definitions.h +++ b/Kernel/Bus/PCI/Definitions.h @@ -300,7 +300,7 @@ struct AK::Formatter : Formatter { { return Formatter::format( builder, - "PCI [{:04x}:{:02x}:{:02x}:{:02x}]", value.domain(), value.bus(), value.device(), value.function()); + "PCI [{:04x}:{:02x}:{:02x}:{:02x}]"sv, value.domain(), value.bus(), value.device(), value.function()); } }; @@ -310,6 +310,6 @@ struct AK::Formatter : Formatter { { return Formatter::format( builder, - "PCI::HardwareID [{:04x}:{:04x}]", value.vendor_id, value.device_id); + "PCI::HardwareID [{:04x}:{:04x}]"sv, value.vendor_id, value.device_id); } }; diff --git a/Kernel/Bus/PCI/Initializer.cpp b/Kernel/Bus/PCI/Initializer.cpp index 2d3de9deacb..a6a91623686 100644 --- a/Kernel/Bus/PCI/Initializer.cpp +++ b/Kernel/Bus/PCI/Initializer.cpp @@ -24,7 +24,7 @@ static bool test_pci_io(); UNMAP_AFTER_INIT static PCIAccessLevel detect_optimal_access_type() { auto boot_determined = kernel_command_line().pci_access_level(); - if (!ACPI::is_enabled() || !ACPI::Parser::the()->find_table("MCFG").has_value()) + if (!ACPI::is_enabled() || !ACPI::Parser::the()->find_table("MCFG"sv).has_value()) return PCIAccessLevel::IOAddressing; if (boot_determined != PCIAccessLevel::IOAddressing) @@ -44,7 +44,7 @@ UNMAP_AFTER_INIT void initialize() return; switch (detect_optimal_access_type()) { case PCIAccessLevel::MemoryAddressing: { - auto mcfg = ACPI::Parser::the()->find_table("MCFG"); + auto mcfg = ACPI::Parser::the()->find_table("MCFG"sv); VERIFY(mcfg.has_value()); auto success = Access::initialize_for_multiple_pci_domains(mcfg.value()); VERIFY(success); diff --git a/Kernel/Bus/USB/UHCI/UHCIController.cpp b/Kernel/Bus/USB/UHCI/UHCIController.cpp index 9f3db0a28aa..75ec88c7d2f 100644 --- a/Kernel/Bus/USB/UHCI/UHCIController.cpp +++ b/Kernel/Bus/USB/UHCI/UHCIController.cpp @@ -105,7 +105,7 @@ ErrorOr UHCIController::reset() } // Let's allocate the physical page for the Frame List (which is 4KiB aligned) - m_framelist = TRY(MM.allocate_dma_buffer_page("UHCI Framelist", Memory::Region::Access::Write)); + m_framelist = TRY(MM.allocate_dma_buffer_page("UHCI Framelist"sv, Memory::Region::Access::Write)); dbgln("UHCI: Allocated framelist at physical address {}", m_framelist->physical_page(0)->paddr()); dbgln("UHCI: Framelist is at virtual address {}", m_framelist->vaddr()); write_sofmod(64); // 1mS frame time @@ -139,7 +139,7 @@ UNMAP_AFTER_INIT ErrorOr UHCIController::create_structures() // Now the Transfer Descriptor pool m_transfer_descriptor_pool = TRY(UHCIDescriptorPool::try_create("Transfer Descriptor Pool"sv)); - m_isochronous_transfer_pool = TRY(MM.allocate_dma_buffer_page("UHCI Isochronous Descriptor Pool", Memory::Region::Access::ReadWrite)); + m_isochronous_transfer_pool = TRY(MM.allocate_dma_buffer_page("UHCI Isochronous Descriptor Pool"sv, Memory::Region::Access::ReadWrite)); // Set up the Isochronous Transfer Descriptor list m_iso_td_list.resize(UHCI_NUMBER_OF_ISOCHRONOUS_TDS); @@ -509,7 +509,7 @@ size_t UHCIController::poll_transfer_queue(QueueHead& transfer_queue) ErrorOr UHCIController::spawn_port_process() { RefPtr usb_hotplug_thread; - (void)Process::create_kernel_process(usb_hotplug_thread, TRY(KString::try_create("UHCI Hot Plug Task")), [&] { + (void)Process::create_kernel_process(usb_hotplug_thread, TRY(KString::try_create("UHCI Hot Plug Task"sv)), [&] { for (;;) { if (m_root_hub) m_root_hub->check_for_port_updates(); diff --git a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h index eceb249a39b..007fffc4da7 100644 --- a/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h +++ b/Kernel/Bus/USB/UHCI/UHCIDescriptorPool.h @@ -30,7 +30,7 @@ class UHCIDescriptorPool { public: static ErrorOr>> try_create(StringView name) { - auto pool_memory_block = TRY(MM.allocate_kernel_region(PAGE_SIZE, "UHCI Descriptor Pool", Memory::Region::Access::ReadWrite)); + auto pool_memory_block = TRY(MM.allocate_kernel_region(PAGE_SIZE, "UHCI Descriptor Pool"sv, Memory::Region::Access::ReadWrite)); return adopt_nonnull_own_or_enomem(new (nothrow) UHCIDescriptorPool(move(pool_memory_block), name)); } diff --git a/Kernel/Bus/USB/USBPipe.cpp b/Kernel/Bus/USB/USBPipe.cpp index 6b0ff1f3cd7..b8153cfe2af 100644 --- a/Kernel/Bus/USB/USBPipe.cpp +++ b/Kernel/Bus/USB/USBPipe.cpp @@ -14,7 +14,7 @@ namespace Kernel::USB { ErrorOr> Pipe::try_create_pipe(USBController const& controller, Type type, Direction direction, u8 endpoint_address, u16 max_packet_size, i8 device_address, u8 poll_interval) { - auto dma_region = TRY(MM.allocate_kernel_region(PAGE_SIZE, "USB device DMA buffer", Memory::Region::Access::ReadWrite)); + auto dma_region = TRY(MM.allocate_kernel_region(PAGE_SIZE, "USB device DMA buffer"sv, Memory::Region::Access::ReadWrite)); return adopt_nonnull_own_or_enomem(new (nothrow) Pipe(controller, type, direction, endpoint_address, max_packet_size, poll_interval, device_address, move(dma_region))); } diff --git a/Kernel/Bus/USB/USBPipe.h b/Kernel/Bus/USB/USBPipe.h index 2d432039847..eb01d341776 100644 --- a/Kernel/Bus/USB/USBPipe.h +++ b/Kernel/Bus/USB/USBPipe.h @@ -79,7 +79,7 @@ private: u8 m_poll_interval { 0 }; // Polling interval (in frames) bool m_data_toggle { false }; // Data toggle for stuffing bit - Mutex m_dma_buffer_lock { "USB pipe mutex" }; + Mutex m_dma_buffer_lock { "USB pipe mutex"sv }; NonnullOwnPtr m_dma_buffer; }; diff --git a/Kernel/Bus/VirtIO/Device.cpp b/Kernel/Bus/VirtIO/Device.cpp index 9296dc42133..abe960aa595 100644 --- a/Kernel/Bus/VirtIO/Device.cpp +++ b/Kernel/Bus/VirtIO/Device.cpp @@ -136,7 +136,7 @@ UNMAP_AFTER_INIT void Device::initialize() dbgln_if(VIRTIO_DEBUG, "{}: Failed to round up size={} to pages", m_class_name, mapping.size); continue; } - auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), cfg.bar))), region_size_or_error.value(), "VirtIO MMIO", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); + auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR(pci_address(), cfg.bar))), region_size_or_error.value(), "VirtIO MMIO"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); if (region_or_error.is_error()) { dbgln_if(VIRTIO_DEBUG, "{}: Failed to map bar {} - (size={}) {}", m_class_name, cfg.bar, mapping.size, region_or_error.error()); } else { diff --git a/Kernel/Bus/VirtIO/RNG.cpp b/Kernel/Bus/VirtIO/RNG.cpp index 9c482bfc106..8bcae54b25a 100644 --- a/Kernel/Bus/VirtIO/RNG.cpp +++ b/Kernel/Bus/VirtIO/RNG.cpp @@ -25,7 +25,7 @@ UNMAP_AFTER_INIT void RNG::initialize() } if (success) { finish_init(); - m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIO::RNG", Memory::Region::Access::ReadWrite).release_value(); + m_entropy_buffer = MM.allocate_contiguous_kernel_region(PAGE_SIZE, "VirtIO::RNG"sv, Memory::Region::Access::ReadWrite).release_value(); if (m_entropy_buffer) { memset(m_entropy_buffer->vaddr().as_ptr(), 0, m_entropy_buffer->size()); request_entropy_from_host(); diff --git a/Kernel/CommandLine.cpp b/Kernel/CommandLine.cpp index 1a20968c44a..3ea48cbd5c3 100644 --- a/Kernel/CommandLine.cpp +++ b/Kernel/CommandLine.cpp @@ -13,7 +13,7 @@ namespace Kernel { static char s_cmd_line[1024]; -static constexpr StringView s_embedded_cmd_line = ""; +static constexpr StringView s_embedded_cmd_line = ""sv; static CommandLine* s_the; UNMAP_AFTER_INIT void CommandLine::early_initialize(char const* cmd_line) diff --git a/Kernel/Devices/MemoryDevice.cpp b/Kernel/Devices/MemoryDevice.cpp index 732d4ca5d3e..02e879dc87e 100644 --- a/Kernel/Devices/MemoryDevice.cpp +++ b/Kernel/Devices/MemoryDevice.cpp @@ -67,7 +67,7 @@ ErrorOr MemoryDevice::mmap(Process& process, OpenFileDescriptio range, move(vmobject), 0, - "Mapped Physical Memory", + "Mapped Physical Memory"sv, prot, shared); } diff --git a/Kernel/Devices/PCISerialDevice.h b/Kernel/Devices/PCISerialDevice.h index f92ef97ab83..c53901648fe 100644 --- a/Kernel/Devices/PCISerialDevice.h +++ b/Kernel/Devices/PCISerialDevice.h @@ -31,10 +31,10 @@ private: }; static constexpr BoardDefinition board_definitions[4] = { - { { PCI::VendorID::WCH, 0x3253 }, "WCH CH382 2S", 2, 0, 0xC0, 8, SerialDevice::Baud::Baud115200 }, - { { PCI::VendorID::RedHat, 0x0002 }, "QEMU PCI 16550A", 1, 0, 0, 8, SerialDevice::Baud::Baud115200 }, - { { PCI::VendorID::RedHat, 0x0003 }, "QEMU PCI Dual-port 16550A", 2, 0, 0, 8, SerialDevice::Baud::Baud115200 }, - { { PCI::VendorID::RedHat, 0x0004 }, "QEMU PCI Quad-port 16550A", 4, 0, 0, 8, SerialDevice::Baud::Baud115200 } + { { PCI::VendorID::WCH, 0x3253 }, "WCH CH382 2S"sv, 2, 0, 0xC0, 8, SerialDevice::Baud::Baud115200 }, + { { PCI::VendorID::RedHat, 0x0002 }, "QEMU PCI 16550A"sv, 1, 0, 0, 8, SerialDevice::Baud::Baud115200 }, + { { PCI::VendorID::RedHat, 0x0003 }, "QEMU PCI Dual-port 16550A"sv, 2, 0, 0, 8, SerialDevice::Baud::Baud115200 }, + { { PCI::VendorID::RedHat, 0x0004 }, "QEMU PCI Quad-port 16550A"sv, 4, 0, 0, 8, SerialDevice::Baud::Baud115200 } }; }; diff --git a/Kernel/DoubleBuffer.h b/Kernel/DoubleBuffer.h index b9a86830b53..54bb39bd8cd 100644 --- a/Kernel/DoubleBuffer.h +++ b/Kernel/DoubleBuffer.h @@ -72,7 +72,7 @@ private: size_t m_read_buffer_index { 0 }; size_t m_space_for_writing { 0 }; bool m_empty { true }; - mutable Mutex m_lock { "DoubleBuffer" }; + mutable Mutex m_lock { "DoubleBuffer"sv }; }; } diff --git a/Kernel/FileSystem/DevPtsFS.cpp b/Kernel/FileSystem/DevPtsFS.cpp index ffb1d210132..06d187e284e 100644 --- a/Kernel/FileSystem/DevPtsFS.cpp +++ b/Kernel/FileSystem/DevPtsFS.cpp @@ -103,8 +103,8 @@ ErrorOr DevPtsFSInode::traverse_as_directory(Function(FileSy if (identifier().index() > 1) return ENOTDIR; - TRY(callback({ ".", identifier(), 0 })); - TRY(callback({ "..", identifier(), 0 })); + TRY(callback({ "."sv, identifier(), 0 })); + TRY(callback({ ".."sv, identifier(), 0 })); return SlavePTY::all_instances().with([&](auto& list) -> ErrorOr { StringBuilder builder; diff --git a/Kernel/FileSystem/DevTmpFS.cpp b/Kernel/FileSystem/DevTmpFS.cpp index e6fff851aaa..6c78255a4fb 100644 --- a/Kernel/FileSystem/DevTmpFS.cpp +++ b/Kernel/FileSystem/DevTmpFS.cpp @@ -205,8 +205,8 @@ DevTmpFSDirectoryInode::~DevTmpFSDirectoryInode() = default; ErrorOr DevTmpFSDirectoryInode::traverse_as_directory(Function(FileSystem::DirectoryEntryView const&)> callback) const { MutexLocker locker(m_inode_lock); - TRY(callback({ ".", identifier(), 0 })); - TRY(callback({ "..", identifier(), 0 })); + TRY(callback({ "."sv, identifier(), 0 })); + TRY(callback({ ".."sv, identifier(), 0 })); for (auto& node : m_nodes) { InodeIdentifier identifier = { fsid(), node.index() }; TRY(callback({ node.name(), identifier, 0 })); diff --git a/Kernel/FileSystem/DevTmpFS.h b/Kernel/FileSystem/DevTmpFS.h index e94da24a6ae..4326e04ec59 100644 --- a/Kernel/FileSystem/DevTmpFS.h +++ b/Kernel/FileSystem/DevTmpFS.h @@ -153,7 +153,7 @@ class DevTmpFSRootDirectoryInode final : public DevTmpFSDirectoryInode { public: virtual ~DevTmpFSRootDirectoryInode() override; - virtual StringView name() const override { return "."; } + virtual StringView name() const override { return "."sv; } private: // ^DevTmpFSInode diff --git a/Kernel/FileSystem/FIFO.cpp b/Kernel/FileSystem/FIFO.cpp index 571e70d3df3..259f061d8cc 100644 --- a/Kernel/FileSystem/FIFO.cpp +++ b/Kernel/FileSystem/FIFO.cpp @@ -41,7 +41,7 @@ ErrorOr> FIFO::open_direction_blocking(FIFO:: if (m_writers == 0) { locker.unlock(); - m_write_open_queue.wait_forever("FIFO"); + m_write_open_queue.wait_forever("FIFO"sv); locker.lock(); } } @@ -51,7 +51,7 @@ ErrorOr> FIFO::open_direction_blocking(FIFO:: if (m_readers == 0) { locker.unlock(); - m_read_open_queue.wait_forever("FIFO"); + m_read_open_queue.wait_forever("FIFO"sv); locker.lock(); } } diff --git a/Kernel/FileSystem/FileSystem.h b/Kernel/FileSystem/FileSystem.h index ef50f87c054..e5042448743 100644 --- a/Kernel/FileSystem/FileSystem.h +++ b/Kernel/FileSystem/FileSystem.h @@ -67,7 +67,7 @@ protected: void set_block_size(u64 size) { m_block_size = size; } void set_fragment_size(size_t size) { m_fragment_size = size; } - mutable Mutex m_lock { "FS" }; + mutable Mutex m_lock { "FS"sv }; private: FileSystemID m_fsid; diff --git a/Kernel/FileSystem/ISO9660FileSystem.cpp b/Kernel/FileSystem/ISO9660FileSystem.cpp index 81843c43726..532302a5b3c 100644 --- a/Kernel/FileSystem/ISO9660FileSystem.cpp +++ b/Kernel/FileSystem/ISO9660FileSystem.cpp @@ -239,7 +239,7 @@ ErrorOr ISO9660FS::parse_volume_set() } auto const* header = reinterpret_cast(block->data()); - if (StringView { header->identifier, 5 } != "CD001") { + if (StringView { header->identifier, 5 } != "CD001"sv) { dbgln_if(ISO9660_DEBUG, "Header magic at volume descriptor {} is not valid", current_block_index - first_data_area_block); return EIO; } diff --git a/Kernel/FileSystem/Inode.h b/Kernel/FileSystem/Inode.h index 84c8eca1b7d..befb3a42f2f 100644 --- a/Kernel/FileSystem/Inode.h +++ b/Kernel/FileSystem/Inode.h @@ -109,7 +109,7 @@ protected: void did_modify_contents(); void did_delete_self(); - mutable Mutex m_inode_lock { "Inode" }; + mutable Mutex m_inode_lock { "Inode"sv }; private: FileSystem& m_file_system; diff --git a/Kernel/FileSystem/InodeIdentifier.h b/Kernel/FileSystem/InodeIdentifier.h index 585bbe6905b..2e00f1c8cca 100644 --- a/Kernel/FileSystem/InodeIdentifier.h +++ b/Kernel/FileSystem/InodeIdentifier.h @@ -56,6 +56,6 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, Kernel::InodeIdentifier value) { - return AK::Formatter::format(builder, "{}:{}", value.fsid(), value.index()); + return AK::Formatter::format(builder, "{}:{}"sv, value.fsid(), value.index()); } }; diff --git a/Kernel/FileSystem/Plan9FileSystem.cpp b/Kernel/FileSystem/Plan9FileSystem.cpp index 17336b7b24c..43822bfb2d4 100644 --- a/Kernel/FileSystem/Plan9FileSystem.cpp +++ b/Kernel/FileSystem/Plan9FileSystem.cpp @@ -201,7 +201,7 @@ ErrorOr Plan9FS::initialize() ensure_thread(); Message version_message { *this, Message::Type::Tversion }; - version_message << (u32)m_max_message_size << "9P2000.L"; + version_message << (u32)m_max_message_size << "9P2000.L"sv; TRY(post_message_and_wait_for_a_reply(version_message)); @@ -218,8 +218,8 @@ ErrorOr Plan9FS::initialize() Message attach_message { *this, Message::Type::Tattach }; // FIXME: This needs a user name and an "export" name; but how do we get them? // Perhaps initialize() should accept a string of FS-specific options... - attach_message << root_fid << (u32)-1 << "sergey" - << "/"; + attach_message << root_fid << (u32)-1 << "sergey"sv + << "/"sv; if (m_remote_protocol_version >= ProtocolVersion::v9P2000u) attach_message << (u32)-1; @@ -653,7 +653,7 @@ void Plan9FS::ensure_thread() { SpinlockLocker lock(m_thread_lock); if (!m_thread_running.exchange(true, AK::MemoryOrder::memory_order_acq_rel)) { - auto process_name = KString::try_create("Plan9FS"); + auto process_name = KString::try_create("Plan9FS"sv); if (process_name.is_error()) TODO(); (void)Process::create_kernel_process(m_thread, process_name.release_value(), [&]() { diff --git a/Kernel/FileSystem/Plan9FileSystem.h b/Kernel/FileSystem/Plan9FileSystem.h index 590d3171249..cae3edb872f 100644 --- a/Kernel/FileSystem/Plan9FileSystem.h +++ b/Kernel/FileSystem/Plan9FileSystem.h @@ -135,7 +135,7 @@ private: ProtocolVersion m_remote_protocol_version { ProtocolVersion::v9P2000 }; size_t m_max_message_size { 4 * KiB }; - Mutex m_send_lock { "Plan9FS send" }; + Mutex m_send_lock { "Plan9FS send"sv }; Plan9FSBlockerSet m_completion_blocker; HashMap> m_completions; diff --git a/Kernel/FileSystem/SysFS/Component.cpp b/Kernel/FileSystem/SysFS/Component.cpp index e5c28bd21ca..af366a5880e 100644 --- a/Kernel/FileSystem/SysFS/Component.cpp +++ b/Kernel/FileSystem/SysFS/Component.cpp @@ -35,8 +35,8 @@ ErrorOr SysFSDirectory::traverse_as_directory(FileSystemID fsid, Function< { MutexLocker locker(SysFSComponentRegistry::the().get_lock()); VERIFY(m_parent_directory); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, m_parent_directory->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, m_parent_directory->component_index() }, 0 })); for (auto& component : m_components) { InodeIdentifier identifier = { fsid, component.component_index() }; diff --git a/Kernel/FileSystem/SysFS/RootDirectory.cpp b/Kernel/FileSystem/SysFS/RootDirectory.cpp index 5eb21c5e571..8a5951ebf61 100644 --- a/Kernel/FileSystem/SysFS/RootDirectory.cpp +++ b/Kernel/FileSystem/SysFS/RootDirectory.cpp @@ -20,8 +20,8 @@ NonnullRefPtr SysFSRootDirectory::create() ErrorOr SysFSRootDirectory::traverse_as_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { MutexLocker locker(SysFSComponentRegistry::the().get_lock()); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, 0 }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, 0 }, 0 })); for (auto const& component : m_components) { InodeIdentifier identifier = { fsid, component.component_index() }; diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.cpp b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.cpp index 5ff793575dd..bcd77960dda 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/BusDirectory.cpp @@ -17,8 +17,8 @@ ErrorOr SysFSUSBBusDirectory::traverse_as_directory(FileSystemID fsid, Fun SpinlockLocker lock(m_lock); // Note: if the parent directory is null, it means something bad happened as this should not happen for the USB directory. VERIFY(m_parent_directory); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, m_parent_directory->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, m_parent_directory->component_index() }, 0 })); for (auto const& device_node : m_device_nodes) { InodeIdentifier identifier = { fsid, device_node.component_index() }; diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.cpp b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.cpp index e411fba780b..b18dfc469b9 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.cpp @@ -26,56 +26,56 @@ ErrorOr SysFSUSBDeviceInformation::try_generate(KBufferBuilder& builder) auto array = TRY(JsonArraySerializer<>::try_create(builder)); auto obj = TRY(array.add_object()); - TRY(obj.add("device_address", m_device->address())); - TRY(obj.add("usb_spec_compliance_bcd", m_device->device_descriptor().usb_spec_compliance_bcd)); - TRY(obj.add("device_class", m_device->device_descriptor().device_class)); - TRY(obj.add("device_sub_class", m_device->device_descriptor().device_sub_class)); - TRY(obj.add("device_protocol", m_device->device_descriptor().device_protocol)); - TRY(obj.add("max_packet_size", m_device->device_descriptor().max_packet_size)); - TRY(obj.add("vendor_id", m_device->device_descriptor().vendor_id)); - TRY(obj.add("product_id", m_device->device_descriptor().product_id)); - TRY(obj.add("device_release_bcd", m_device->device_descriptor().device_release_bcd)); - TRY(obj.add("manufacturer_id_descriptor_index", m_device->device_descriptor().manufacturer_id_descriptor_index)); - TRY(obj.add("product_string_descriptor_index", m_device->device_descriptor().product_string_descriptor_index)); - TRY(obj.add("serial_number_descriptor_index", m_device->device_descriptor().serial_number_descriptor_index)); - TRY(obj.add("num_configurations", m_device->device_descriptor().num_configurations)); - TRY(obj.add("length", m_device->device_descriptor().descriptor_header.length)); - TRY(obj.add("descriptor_type", m_device->device_descriptor().descriptor_header.descriptor_type)); + TRY(obj.add("device_address"sv, m_device->address())); + TRY(obj.add("usb_spec_compliance_bcd"sv, m_device->device_descriptor().usb_spec_compliance_bcd)); + TRY(obj.add("device_class"sv, m_device->device_descriptor().device_class)); + TRY(obj.add("device_sub_class"sv, m_device->device_descriptor().device_sub_class)); + TRY(obj.add("device_protocol"sv, m_device->device_descriptor().device_protocol)); + TRY(obj.add("max_packet_size"sv, m_device->device_descriptor().max_packet_size)); + TRY(obj.add("vendor_id"sv, m_device->device_descriptor().vendor_id)); + TRY(obj.add("product_id"sv, m_device->device_descriptor().product_id)); + TRY(obj.add("device_release_bcd"sv, m_device->device_descriptor().device_release_bcd)); + TRY(obj.add("manufacturer_id_descriptor_index"sv, m_device->device_descriptor().manufacturer_id_descriptor_index)); + TRY(obj.add("product_string_descriptor_index"sv, m_device->device_descriptor().product_string_descriptor_index)); + TRY(obj.add("serial_number_descriptor_index"sv, m_device->device_descriptor().serial_number_descriptor_index)); + TRY(obj.add("num_configurations"sv, m_device->device_descriptor().num_configurations)); + TRY(obj.add("length"sv, m_device->device_descriptor().descriptor_header.length)); + TRY(obj.add("descriptor_type"sv, m_device->device_descriptor().descriptor_header.descriptor_type)); - auto configuration_array = TRY(obj.add_array("configurations")); + auto configuration_array = TRY(obj.add_array("configurations"sv)); for (auto const& configuration : m_device->configurations()) { auto configuration_object = TRY(configuration_array.add_object()); auto const& configuration_descriptor = configuration.descriptor(); - TRY(configuration_object.add("length", configuration_descriptor.descriptor_header.length)); - TRY(configuration_object.add("descriptor_type", configuration_descriptor.descriptor_header.descriptor_type)); - TRY(configuration_object.add("total_length", configuration_descriptor.total_length)); - TRY(configuration_object.add("number_of_interfaces", configuration_descriptor.number_of_interfaces)); - TRY(configuration_object.add("attributes_bitmap", configuration_descriptor.attributes_bitmap)); - TRY(configuration_object.add("max_power", configuration_descriptor.max_power_in_ma)); + TRY(configuration_object.add("length"sv, configuration_descriptor.descriptor_header.length)); + TRY(configuration_object.add("descriptor_type"sv, configuration_descriptor.descriptor_header.descriptor_type)); + TRY(configuration_object.add("total_length"sv, configuration_descriptor.total_length)); + TRY(configuration_object.add("number_of_interfaces"sv, configuration_descriptor.number_of_interfaces)); + TRY(configuration_object.add("attributes_bitmap"sv, configuration_descriptor.attributes_bitmap)); + TRY(configuration_object.add("max_power"sv, configuration_descriptor.max_power_in_ma)); - auto interface_array = TRY(configuration_object.add_array("interfaces")); + auto interface_array = TRY(configuration_object.add_array("interfaces"sv)); for (auto const& interface : configuration.interfaces()) { auto interface_object = TRY(interface_array.add_object()); auto const& interface_descriptor = interface.descriptor(); - TRY(interface_object.add("length", interface_descriptor.descriptor_header.length)); - TRY(interface_object.add("descriptor_type", interface_descriptor.descriptor_header.descriptor_type)); - TRY(interface_object.add("interface_number", interface_descriptor.interface_id)); - TRY(interface_object.add("alternate_setting", interface_descriptor.alternate_setting)); - TRY(interface_object.add("num_endpoints", interface_descriptor.number_of_endpoints)); - TRY(interface_object.add("interface_class_code", interface_descriptor.interface_class_code)); - TRY(interface_object.add("interface_sub_class_code", interface_descriptor.interface_sub_class_code)); - TRY(interface_object.add("interface_protocol", interface_descriptor.interface_protocol)); - TRY(interface_object.add("interface_string_desc_index", interface_descriptor.interface_string_descriptor_index)); + TRY(interface_object.add("length"sv, interface_descriptor.descriptor_header.length)); + TRY(interface_object.add("descriptor_type"sv, interface_descriptor.descriptor_header.descriptor_type)); + TRY(interface_object.add("interface_number"sv, interface_descriptor.interface_id)); + TRY(interface_object.add("alternate_setting"sv, interface_descriptor.alternate_setting)); + TRY(interface_object.add("num_endpoints"sv, interface_descriptor.number_of_endpoints)); + TRY(interface_object.add("interface_class_code"sv, interface_descriptor.interface_class_code)); + TRY(interface_object.add("interface_sub_class_code"sv, interface_descriptor.interface_sub_class_code)); + TRY(interface_object.add("interface_protocol"sv, interface_descriptor.interface_protocol)); + TRY(interface_object.add("interface_string_desc_index"sv, interface_descriptor.interface_string_descriptor_index)); - auto endpoint_array = TRY(interface_object.add_array("endpoints")); + auto endpoint_array = TRY(interface_object.add_array("endpoints"sv)); for (auto const& endpoint : interface.endpoints()) { auto endpoint_object = TRY(endpoint_array.add_object()); - TRY(endpoint_object.add("length", endpoint.descriptor_header.length)); - TRY(endpoint_object.add("descriptor_length", endpoint.descriptor_header.descriptor_type)); - TRY(endpoint_object.add("endpoint_address", endpoint.endpoint_address)); - TRY(endpoint_object.add("attribute_bitmap", endpoint.endpoint_attributes_bitmap)); - TRY(endpoint_object.add("max_packet_size", endpoint.max_packet_size)); - TRY(endpoint_object.add("polling_interval", endpoint.poll_interval_in_frames)); + TRY(endpoint_object.add("length"sv, endpoint.descriptor_header.length)); + TRY(endpoint_object.add("descriptor_length"sv, endpoint.descriptor_header.descriptor_type)); + TRY(endpoint_object.add("endpoint_address"sv, endpoint.endpoint_address)); + TRY(endpoint_object.add("attribute_bitmap"sv, endpoint.endpoint_attributes_bitmap)); + TRY(endpoint_object.add("max_packet_size"sv, endpoint.max_packet_size)); + TRY(endpoint_object.add("polling_interval"sv, endpoint.poll_interval_in_frames)); TRY(endpoint_object.finish()); } TRY(endpoint_array.finish()); diff --git a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.h b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.h index 9ccae417427..07f074a45d9 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.h +++ b/Kernel/FileSystem/SysFS/Subsystems/Bus/USB/DeviceInformation.h @@ -37,7 +37,7 @@ protected: private: ErrorOr try_generate(KBufferBuilder&); virtual ErrorOr refresh_data(OpenFileDescription& description) const override; - mutable Mutex m_lock { "SysFSUSBDeviceInformation" }; + mutable Mutex m_lock { "SysFSUSBDeviceInformation"sv }; NonnullOwnPtr m_device_name; }; diff --git a/Kernel/FileSystem/SysFS/Subsystems/Devices/BlockDevicesDirectory.cpp b/Kernel/FileSystem/SysFS/Subsystems/Devices/BlockDevicesDirectory.cpp index 3dcefd70bc2..21a95c3ef5c 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Devices/BlockDevicesDirectory.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Devices/BlockDevicesDirectory.cpp @@ -22,8 +22,8 @@ SysFSBlockDevicesDirectory::SysFSBlockDevicesDirectory(SysFSDevicesDirectory con ErrorOr SysFSBlockDevicesDirectory::traverse_as_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { VERIFY(m_parent_directory); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, m_parent_directory->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, m_parent_directory->component_index() }, 0 })); return SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> ErrorOr { for (auto& exposed_device : list) { diff --git a/Kernel/FileSystem/SysFS/Subsystems/Devices/CharacterDevicesDirectory.cpp b/Kernel/FileSystem/SysFS/Subsystems/Devices/CharacterDevicesDirectory.cpp index 0d09be1b686..3c3f65ba345 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Devices/CharacterDevicesDirectory.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Devices/CharacterDevicesDirectory.cpp @@ -21,8 +21,8 @@ SysFSCharacterDevicesDirectory::SysFSCharacterDevicesDirectory(SysFSDevicesDirec ErrorOr SysFSCharacterDevicesDirectory::traverse_as_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { VERIFY(m_parent_directory); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, m_parent_directory->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, m_parent_directory->component_index() }, 0 })); return SysFSComponentRegistry::the().devices_list().with_exclusive([&](auto& list) -> ErrorOr { for (auto& exposed_device : list) { diff --git a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.cpp b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.cpp index 665fe1e6353..5fa0c6def05 100644 --- a/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.cpp +++ b/Kernel/FileSystem/SysFS/Subsystems/Firmware/BIOS/Directory.cpp @@ -96,7 +96,7 @@ UNMAP_AFTER_INIT Optional BIOSSysFSDirectory::find_dmi_entry64b auto bios_or_error = map_bios(); if (bios_or_error.is_error()) return {}; - return bios_or_error.value().find_chunk_starting_with("_SM3_", 16); + return bios_or_error.value().find_chunk_starting_with("_SM3_"sv, 16); } UNMAP_AFTER_INIT Optional BIOSSysFSDirectory::find_dmi_entry32bit_point() @@ -104,7 +104,7 @@ UNMAP_AFTER_INIT Optional BIOSSysFSDirectory::find_dmi_entry32b auto bios_or_error = map_bios(); if (bios_or_error.is_error()) return {}; - return bios_or_error.value().find_chunk_starting_with("_SM_", 16); + return bios_or_error.value().find_chunk_starting_with("_SM_"sv, 16); } } diff --git a/Kernel/FileSystem/TmpFS.cpp b/Kernel/FileSystem/TmpFS.cpp index b8e58f094c1..2c4ba998913 100644 --- a/Kernel/FileSystem/TmpFS.cpp +++ b/Kernel/FileSystem/TmpFS.cpp @@ -77,9 +77,9 @@ ErrorOr TmpFSInode::traverse_as_directory(Function(FileSyste if (!is_directory()) return ENOTDIR; - TRY(callback({ ".", identifier(), 0 })); + TRY(callback({ "."sv, identifier(), 0 })); if (auto parent = m_parent.strong_ref()) - TRY(callback({ "..", parent->identifier(), 0 })); + TRY(callback({ ".."sv, parent->identifier(), 0 })); for (auto& child : m_children) { TRY(callback({ child.name->view(), child.inode->identifier(), 0 })); diff --git a/Kernel/FileSystem/VirtualFileSystem.cpp b/Kernel/FileSystem/VirtualFileSystem.cpp index 1c29b4f4bd2..d17530e3442 100644 --- a/Kernel/FileSystem/VirtualFileSystem.cpp +++ b/Kernel/FileSystem/VirtualFileSystem.cpp @@ -128,7 +128,7 @@ ErrorOr VirtualFileSystem::mount_root(FileSystem& fs) mounts.append(move(mount)); }); - m_root_custody = TRY(Custody::try_create(nullptr, "", *m_root_inode, root_mount_flags)); + m_root_custody = TRY(Custody::try_create(nullptr, ""sv, *m_root_inode, root_mount_flags)); return {}; } @@ -376,7 +376,7 @@ ErrorOr VirtualFileSystem::mkdir(StringView path, mode_t mode, Custody& ba path = path.trim("/"sv, TrimMode::Right); if (path.is_empty()) { // NOTE: This means the path was a series of slashes, which resolves to "/". - path = "/"; + path = "/"sv; } RefPtr parent_custody; @@ -736,8 +736,8 @@ ErrorOr VirtualFileSystem::rmdir(StringView path, Custody& base) if (custody->is_readonly()) return EROFS; - TRY(inode.remove_child(".")); - TRY(inode.remove_child("..")); + TRY(inode.remove_child("."sv)); + TRY(inode.remove_child(".."sv)); return parent_inode.remove_child(KLexicalPath::basename(path)); } diff --git a/Kernel/Firmware/ACPI/Initialize.cpp b/Kernel/Firmware/ACPI/Initialize.cpp index 890bed30f64..5588080a6f2 100644 --- a/Kernel/Firmware/ACPI/Initialize.cpp +++ b/Kernel/Firmware/ACPI/Initialize.cpp @@ -22,7 +22,7 @@ UNMAP_AFTER_INIT void initialize() if (!rsdp.has_value()) return; - auto facp = StaticParsing::find_table(rsdp.value(), "FACP"); + auto facp = StaticParsing::find_table(rsdp.value(), "FACP"sv); if (!facp.has_value()) return; auto facp_table_or_error = Memory::map_typed(facp.value()); diff --git a/Kernel/Firmware/ACPI/Parser.cpp b/Kernel/Firmware/ACPI/Parser.cpp index fa3439432fe..5be352e4f20 100644 --- a/Kernel/Firmware/ACPI/Parser.cpp +++ b/Kernel/Firmware/ACPI/Parser.cpp @@ -84,13 +84,13 @@ UNMAP_AFTER_INIT void ACPISysFSDirectory::find_tables_and_register_them_as_compo m_components = components; auto rsdp = Memory::map_typed(ACPI::Parser::the()->rsdp()).release_value_but_fixme_should_propagate_errors(); - m_components.append(ACPISysFSComponent::create("RSDP", ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length)); + m_components.append(ACPISysFSComponent::create("RSDP"sv, ACPI::Parser::the()->rsdp(), rsdp->base.revision == 0 ? sizeof(Structures::RSDPDescriptor) : rsdp->length)); auto main_system_description_table = Memory::map_typed(ACPI::Parser::the()->main_system_description_table()).release_value_but_fixme_should_propagate_errors(); if (ACPI::Parser::the()->is_xsdt_supported()) { - m_components.append(ACPISysFSComponent::create("XSDT", ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length)); + m_components.append(ACPISysFSComponent::create("XSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length)); } else { - m_components.append(ACPISysFSComponent::create("RSDT", ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length)); + m_components.append(ACPISysFSComponent::create("RSDT"sv, ACPI::Parser::the()->main_system_description_table(), main_system_description_table->length)); } } diff --git a/Kernel/GlobalProcessExposed.cpp b/Kernel/GlobalProcessExposed.cpp index 8df53cbf6e8..a0acdb07789 100644 --- a/Kernel/GlobalProcessExposed.cpp +++ b/Kernel/GlobalProcessExposed.cpp @@ -46,24 +46,24 @@ private: auto array = TRY(JsonArraySerializer<>::try_create(builder)); TRY(NetworkingManagement::the().try_for_each([&array](auto& adapter) -> ErrorOr { auto obj = TRY(array.add_object()); - TRY(obj.add("name", adapter.name())); - TRY(obj.add("class_name", adapter.class_name())); + TRY(obj.add("name"sv, adapter.name())); + TRY(obj.add("class_name"sv, adapter.class_name())); auto mac_address = TRY(adapter.mac_address().to_string()); - TRY(obj.add("mac_address", mac_address->view())); + TRY(obj.add("mac_address"sv, mac_address->view())); if (!adapter.ipv4_address().is_zero()) { auto ipv4_address = TRY(adapter.ipv4_address().to_string()); - TRY(obj.add("ipv4_address", ipv4_address->view())); + TRY(obj.add("ipv4_address"sv, ipv4_address->view())); auto ipv4_netmask = TRY(adapter.ipv4_netmask().to_string()); - TRY(obj.add("ipv4_netmask", ipv4_netmask->view())); + TRY(obj.add("ipv4_netmask"sv, ipv4_netmask->view())); } - TRY(obj.add("packets_in", adapter.packets_in())); - TRY(obj.add("bytes_in", adapter.bytes_in())); - TRY(obj.add("packets_out", adapter.packets_out())); - TRY(obj.add("bytes_out", adapter.bytes_out())); - TRY(obj.add("link_up", adapter.link_up())); - TRY(obj.add("link_speed", adapter.link_speed())); - TRY(obj.add("link_full_duplex", adapter.link_full_duplex())); - TRY(obj.add("mtu", adapter.mtu())); + TRY(obj.add("packets_in"sv, adapter.packets_in())); + TRY(obj.add("bytes_in"sv, adapter.bytes_in())); + TRY(obj.add("packets_out"sv, adapter.packets_out())); + TRY(obj.add("bytes_out"sv, adapter.bytes_out())); + TRY(obj.add("link_up"sv, adapter.link_up())); + TRY(obj.add("link_speed"sv, adapter.link_speed())); + TRY(obj.add("link_full_duplex"sv, adapter.link_full_duplex())); + TRY(obj.add("mtu"sv, adapter.mtu())); TRY(obj.finish()); return {}; })); @@ -85,9 +85,9 @@ private: for (auto& it : table) { auto obj = TRY(array.add_object()); auto mac_address = TRY(it.value.to_string()); - TRY(obj.add("mac_address", mac_address->view())); + TRY(obj.add("mac_address"sv, mac_address->view())); auto ip_address = TRY(it.key.to_string()); - TRY(obj.add("ip_address", ip_address->view())); + TRY(obj.add("ip_address"sv, ip_address->view())); TRY(obj.finish()); } return {}; @@ -110,13 +110,13 @@ private: for (auto& it : table) { auto obj = TRY(array.add_object()); auto destination = TRY(it.destination.to_string()); - TRY(obj.add("destination", destination->view())); + TRY(obj.add("destination"sv, destination->view())); auto gateway = TRY(it.gateway.to_string()); - TRY(obj.add("gateway", gateway->view())); + TRY(obj.add("gateway"sv, gateway->view())); auto netmask = TRY(it.netmask.to_string()); - TRY(obj.add("genmask", netmask->view())); - TRY(obj.add("flags", it.flags)); - TRY(obj.add("interface", it.adapter->name())); + TRY(obj.add("genmask"sv, netmask->view())); + TRY(obj.add("flags"sv, it.flags)); + TRY(obj.add("interface"sv, it.adapter->name())); TRY(obj.finish()); } return {}; @@ -138,22 +138,22 @@ private: TRY(TCPSocket::try_for_each([&array](auto& socket) -> ErrorOr { auto obj = TRY(array.add_object()); auto local_address = TRY(socket.local_address().to_string()); - TRY(obj.add("local_address", local_address->view())); - TRY(obj.add("local_port", socket.local_port())); + TRY(obj.add("local_address"sv, local_address->view())); + TRY(obj.add("local_port"sv, socket.local_port())); auto peer_address = TRY(socket.peer_address().to_string()); - TRY(obj.add("peer_address", peer_address->view())); - TRY(obj.add("peer_port", socket.peer_port())); - TRY(obj.add("state", TCPSocket::to_string(socket.state()))); - TRY(obj.add("ack_number", socket.ack_number())); - TRY(obj.add("sequence_number", socket.sequence_number())); - TRY(obj.add("packets_in", socket.packets_in())); - TRY(obj.add("bytes_in", socket.bytes_in())); - TRY(obj.add("packets_out", socket.packets_out())); - TRY(obj.add("bytes_out", socket.bytes_out())); + TRY(obj.add("peer_address"sv, peer_address->view())); + TRY(obj.add("peer_port"sv, socket.peer_port())); + TRY(obj.add("state"sv, TCPSocket::to_string(socket.state()))); + TRY(obj.add("ack_number"sv, socket.ack_number())); + TRY(obj.add("sequence_number"sv, socket.sequence_number())); + TRY(obj.add("packets_in"sv, socket.packets_in())); + TRY(obj.add("bytes_in"sv, socket.bytes_in())); + TRY(obj.add("packets_out"sv, socket.packets_out())); + TRY(obj.add("bytes_out"sv, socket.bytes_out())); if (Process::current().is_superuser() || Process::current().uid() == socket.origin_uid()) { - TRY(obj.add("origin_pid", socket.origin_pid().value())); - TRY(obj.add("origin_uid", socket.origin_uid().value())); - TRY(obj.add("origin_gid", socket.origin_gid().value())); + TRY(obj.add("origin_pid"sv, socket.origin_pid().value())); + TRY(obj.add("origin_uid"sv, socket.origin_uid().value())); + TRY(obj.add("origin_gid"sv, socket.origin_gid().value())); } TRY(obj.finish()); return {}; @@ -174,13 +174,13 @@ private: auto array = TRY(JsonArraySerializer<>::try_create(builder)); TRY(LocalSocket::try_for_each([&array](auto& socket) -> ErrorOr { auto obj = TRY(array.add_object()); - TRY(obj.add("path", socket.socket_path())); - TRY(obj.add("origin_pid", socket.origin_pid().value())); - TRY(obj.add("origin_uid", socket.origin_uid().value())); - TRY(obj.add("origin_gid", socket.origin_gid().value())); - TRY(obj.add("acceptor_pid", socket.acceptor_pid().value())); - TRY(obj.add("acceptor_uid", socket.acceptor_uid().value())); - TRY(obj.add("acceptor_gid", socket.acceptor_gid().value())); + TRY(obj.add("path"sv, socket.socket_path())); + TRY(obj.add("origin_pid"sv, socket.origin_pid().value())); + TRY(obj.add("origin_uid"sv, socket.origin_uid().value())); + TRY(obj.add("origin_gid"sv, socket.origin_gid().value())); + TRY(obj.add("acceptor_pid"sv, socket.acceptor_pid().value())); + TRY(obj.add("acceptor_uid"sv, socket.acceptor_uid().value())); + TRY(obj.add("acceptor_gid"sv, socket.acceptor_gid().value())); TRY(obj.finish()); return {}; })); @@ -201,15 +201,15 @@ private: TRY(UDPSocket::try_for_each([&array](auto& socket) -> ErrorOr { auto obj = TRY(array.add_object()); auto local_address = TRY(socket.local_address().to_string()); - TRY(obj.add("local_address", local_address->view())); - TRY(obj.add("local_port", socket.local_port())); + TRY(obj.add("local_address"sv, local_address->view())); + TRY(obj.add("local_port"sv, socket.local_port())); auto peer_address = TRY(socket.peer_address().to_string()); - TRY(obj.add("peer_address", peer_address->view())); - TRY(obj.add("peer_port", socket.peer_port())); + TRY(obj.add("peer_address"sv, peer_address->view())); + TRY(obj.add("peer_port"sv, socket.peer_port())); if (Process::current().is_superuser() || Process::current().uid() == socket.origin_uid()) { - TRY(obj.add("origin_pid", socket.origin_pid().value())); - TRY(obj.add("origin_uid", socket.origin_uid().value())); - TRY(obj.add("origin_gid", socket.origin_gid().value())); + TRY(obj.add("origin_pid"sv, socket.origin_pid().value())); + TRY(obj.add("origin_uid"sv, socket.origin_uid().value())); + TRY(obj.add("origin_gid"sv, socket.origin_gid().value())); } TRY(obj.finish()); return {}; @@ -402,22 +402,22 @@ private: TRY(VirtualFileSystem::the().for_each_mount([&array](auto& mount) -> ErrorOr { auto& fs = mount.guest_fs(); auto fs_object = TRY(array.add_object()); - TRY(fs_object.add("class_name", fs.class_name())); - TRY(fs_object.add("total_block_count", fs.total_block_count())); - TRY(fs_object.add("free_block_count", fs.free_block_count())); - TRY(fs_object.add("total_inode_count", fs.total_inode_count())); - TRY(fs_object.add("free_inode_count", fs.free_inode_count())); + TRY(fs_object.add("class_name"sv, fs.class_name())); + TRY(fs_object.add("total_block_count"sv, fs.total_block_count())); + TRY(fs_object.add("free_block_count"sv, fs.free_block_count())); + TRY(fs_object.add("total_inode_count"sv, fs.total_inode_count())); + TRY(fs_object.add("free_inode_count"sv, fs.free_inode_count())); auto mount_point = TRY(mount.absolute_path()); - TRY(fs_object.add("mount_point", mount_point->view())); - TRY(fs_object.add("block_size", static_cast(fs.block_size()))); - TRY(fs_object.add("readonly", fs.is_readonly())); - TRY(fs_object.add("mount_flags", mount.flags())); + TRY(fs_object.add("mount_point"sv, mount_point->view())); + TRY(fs_object.add("block_size"sv, static_cast(fs.block_size()))); + TRY(fs_object.add("readonly"sv, fs.is_readonly())); + TRY(fs_object.add("mount_flags"sv, mount.flags())); if (fs.is_file_backed()) { auto pseudo_path = TRY(static_cast(fs).file_description().pseudo_path()); - TRY(fs_object.add("source", pseudo_path->view())); + TRY(fs_object.add("source"sv, pseudo_path->view())); } else { - TRY(fs_object.add("source", "none")); + TRY(fs_object.add("source"sv, "none")); } TRY(fs_object.finish()); @@ -444,16 +444,16 @@ private: auto system_memory = MM.get_system_memory_info(); auto json = TRY(JsonObjectSerializer<>::try_create(builder)); - TRY(json.add("kmalloc_allocated", stats.bytes_allocated)); - TRY(json.add("kmalloc_available", stats.bytes_free)); - TRY(json.add("user_physical_allocated", system_memory.user_physical_pages_used)); - TRY(json.add("user_physical_available", system_memory.user_physical_pages - system_memory.user_physical_pages_used)); - TRY(json.add("user_physical_committed", system_memory.user_physical_pages_committed)); - TRY(json.add("user_physical_uncommitted", system_memory.user_physical_pages_uncommitted)); - TRY(json.add("super_physical_allocated", system_memory.super_physical_pages_used)); - TRY(json.add("super_physical_available", system_memory.super_physical_pages - system_memory.super_physical_pages_used)); - TRY(json.add("kmalloc_call_count", stats.kmalloc_call_count)); - TRY(json.add("kfree_call_count", stats.kfree_call_count)); + TRY(json.add("kmalloc_allocated"sv, stats.bytes_allocated)); + TRY(json.add("kmalloc_available"sv, stats.bytes_free)); + TRY(json.add("user_physical_allocated"sv, system_memory.user_physical_pages_used)); + TRY(json.add("user_physical_available"sv, system_memory.user_physical_pages - system_memory.user_physical_pages_used)); + TRY(json.add("user_physical_committed"sv, system_memory.user_physical_pages_committed)); + TRY(json.add("user_physical_uncommitted"sv, system_memory.user_physical_pages_uncommitted)); + TRY(json.add("super_physical_allocated"sv, system_memory.super_physical_pages_used)); + TRY(json.add("super_physical_available"sv, system_memory.super_physical_pages - system_memory.super_physical_pages_used)); + TRY(json.add("kmalloc_call_count"sv, stats.kmalloc_call_count)); + TRY(json.add("kfree_call_count"sv, stats.kfree_call_count)); TRY(json.finish()); return {}; } @@ -469,14 +469,14 @@ private: { auto json = TRY(JsonObjectSerializer<>::try_create(builder)); auto total_time_scheduled = Scheduler::get_total_time_scheduled(); - TRY(json.add("total_time", total_time_scheduled.total)); - TRY(json.add("kernel_time", total_time_scheduled.total_kernel)); - TRY(json.add("user_time", total_time_scheduled.total - total_time_scheduled.total_kernel)); + TRY(json.add("total_time"sv, total_time_scheduled.total)); + TRY(json.add("kernel_time"sv, total_time_scheduled.total_kernel)); + TRY(json.add("user_time"sv, total_time_scheduled.total - total_time_scheduled.total_kernel)); u64 idle_time = 0; Processor::for_each([&](Processor& processor) { idle_time += processor.time_spent_idle(); }); - TRY(json.add("idle_time", idle_time)); + TRY(json.add("idle_time"sv, idle_time)); TRY(json.finish()); return {}; } @@ -501,78 +501,78 @@ private: #define __ENUMERATE_PLEDGE_PROMISE(promise) \ if (process.has_promised(Pledge::promise)) \ - TRY(pledge_builder.try_append(#promise " ")); + TRY(pledge_builder.try_append(#promise " "sv)); ENUMERATE_PLEDGE_PROMISES #undef __ENUMERATE_PLEDGE_PROMISE - TRY(process_object.add("pledge", pledge_builder.string_view())); + TRY(process_object.add("pledge"sv, pledge_builder.string_view())); switch (process.veil_state()) { case VeilState::None: - TRY(process_object.add("veil", "None")); + TRY(process_object.add("veil"sv, "None")); break; case VeilState::Dropped: - TRY(process_object.add("veil", "Dropped")); + TRY(process_object.add("veil"sv, "Dropped")); break; case VeilState::Locked: - TRY(process_object.add("veil", "Locked")); + TRY(process_object.add("veil"sv, "Locked")); break; } } else { - TRY(process_object.add("pledge", ""sv)); - TRY(process_object.add("veil", ""sv)); + TRY(process_object.add("pledge"sv, ""sv)); + TRY(process_object.add("veil"sv, ""sv)); } - TRY(process_object.add("pid", process.pid().value())); - TRY(process_object.add("pgid", process.tty() ? process.tty()->pgid().value() : 0)); - TRY(process_object.add("pgp", process.pgid().value())); - TRY(process_object.add("sid", process.sid().value())); - TRY(process_object.add("uid", process.uid().value())); - TRY(process_object.add("gid", process.gid().value())); - TRY(process_object.add("ppid", process.ppid().value())); + TRY(process_object.add("pid"sv, process.pid().value())); + TRY(process_object.add("pgid"sv, process.tty() ? process.tty()->pgid().value() : 0)); + TRY(process_object.add("pgp"sv, process.pgid().value())); + TRY(process_object.add("sid"sv, process.sid().value())); + TRY(process_object.add("uid"sv, process.uid().value())); + TRY(process_object.add("gid"sv, process.gid().value())); + TRY(process_object.add("ppid"sv, process.ppid().value())); if (process.tty()) { auto tty_pseudo_name = TRY(process.tty()->pseudo_name()); - TRY(process_object.add("tty", tty_pseudo_name->view())); + TRY(process_object.add("tty"sv, tty_pseudo_name->view())); } else { - TRY(process_object.add("tty", "")); + TRY(process_object.add("tty"sv, "")); } - TRY(process_object.add("nfds", process.fds().with_shared([](auto& fds) { return fds.open_count(); }))); - TRY(process_object.add("name", process.name())); - TRY(process_object.add("executable", process.executable() ? TRY(process.executable()->try_serialize_absolute_path())->view() : ""sv)); - TRY(process_object.add("amount_virtual", process.address_space().amount_virtual())); - TRY(process_object.add("amount_resident", process.address_space().amount_resident())); - TRY(process_object.add("amount_dirty_private", process.address_space().amount_dirty_private())); - TRY(process_object.add("amount_clean_inode", TRY(process.address_space().amount_clean_inode()))); - TRY(process_object.add("amount_shared", process.address_space().amount_shared())); - TRY(process_object.add("amount_purgeable_volatile", process.address_space().amount_purgeable_volatile())); - TRY(process_object.add("amount_purgeable_nonvolatile", process.address_space().amount_purgeable_nonvolatile())); - TRY(process_object.add("dumpable", process.is_dumpable())); - TRY(process_object.add("kernel", process.is_kernel_process())); - auto thread_array = TRY(process_object.add_array("threads")); + TRY(process_object.add("nfds"sv, process.fds().with_shared([](auto& fds) { return fds.open_count(); }))); + TRY(process_object.add("name"sv, process.name())); + TRY(process_object.add("executable"sv, process.executable() ? TRY(process.executable()->try_serialize_absolute_path())->view() : ""sv)); + TRY(process_object.add("amount_virtual"sv, process.address_space().amount_virtual())); + TRY(process_object.add("amount_resident"sv, process.address_space().amount_resident())); + TRY(process_object.add("amount_dirty_private"sv, process.address_space().amount_dirty_private())); + TRY(process_object.add("amount_clean_inode"sv, TRY(process.address_space().amount_clean_inode()))); + TRY(process_object.add("amount_shared"sv, process.address_space().amount_shared())); + TRY(process_object.add("amount_purgeable_volatile"sv, process.address_space().amount_purgeable_volatile())); + TRY(process_object.add("amount_purgeable_nonvolatile"sv, process.address_space().amount_purgeable_nonvolatile())); + TRY(process_object.add("dumpable"sv, process.is_dumpable())); + TRY(process_object.add("kernel"sv, process.is_kernel_process())); + auto thread_array = TRY(process_object.add_array("threads"sv)); TRY(process.try_for_each_thread([&](const Thread& thread) -> ErrorOr { SpinlockLocker locker(thread.get_lock()); auto thread_object = TRY(thread_array.add_object()); #if LOCK_DEBUG - TRY(thread_object.add("lock_count", thread.lock_count())); + TRY(thread_object.add("lock_count"sv, thread.lock_count())); #endif - TRY(thread_object.add("tid", thread.tid().value())); - TRY(thread_object.add("name", thread.name())); - TRY(thread_object.add("times_scheduled", thread.times_scheduled())); - TRY(thread_object.add("time_user", thread.time_in_user())); - TRY(thread_object.add("time_kernel", thread.time_in_kernel())); - TRY(thread_object.add("state", thread.state_string())); - TRY(thread_object.add("cpu", thread.cpu())); - TRY(thread_object.add("priority", thread.priority())); - TRY(thread_object.add("syscall_count", thread.syscall_count())); - TRY(thread_object.add("inode_faults", thread.inode_faults())); - TRY(thread_object.add("zero_faults", thread.zero_faults())); - TRY(thread_object.add("cow_faults", thread.cow_faults())); - TRY(thread_object.add("file_read_bytes", thread.file_read_bytes())); - TRY(thread_object.add("file_write_bytes", thread.file_write_bytes())); - TRY(thread_object.add("unix_socket_read_bytes", thread.unix_socket_read_bytes())); - TRY(thread_object.add("unix_socket_write_bytes", thread.unix_socket_write_bytes())); - TRY(thread_object.add("ipv4_socket_read_bytes", thread.ipv4_socket_read_bytes())); - TRY(thread_object.add("ipv4_socket_write_bytes", thread.ipv4_socket_write_bytes())); + TRY(thread_object.add("tid"sv, thread.tid().value())); + TRY(thread_object.add("name"sv, thread.name())); + TRY(thread_object.add("times_scheduled"sv, thread.times_scheduled())); + TRY(thread_object.add("time_user"sv, thread.time_in_user())); + TRY(thread_object.add("time_kernel"sv, thread.time_in_kernel())); + TRY(thread_object.add("state"sv, thread.state_string())); + TRY(thread_object.add("cpu"sv, thread.cpu())); + TRY(thread_object.add("priority"sv, thread.priority())); + TRY(thread_object.add("syscall_count"sv, thread.syscall_count())); + TRY(thread_object.add("inode_faults"sv, thread.inode_faults())); + TRY(thread_object.add("zero_faults"sv, thread.zero_faults())); + TRY(thread_object.add("cow_faults"sv, thread.cow_faults())); + TRY(thread_object.add("file_read_bytes"sv, thread.file_read_bytes())); + TRY(thread_object.add("file_write_bytes"sv, thread.file_write_bytes())); + TRY(thread_object.add("unix_socket_read_bytes"sv, thread.unix_socket_read_bytes())); + TRY(thread_object.add("unix_socket_write_bytes"sv, thread.unix_socket_write_bytes())); + TRY(thread_object.add("ipv4_socket_read_bytes"sv, thread.ipv4_socket_read_bytes())); + TRY(thread_object.add("ipv4_socket_write_bytes"sv, thread.ipv4_socket_write_bytes())); TRY(thread_object.finish()); return {}; @@ -585,7 +585,7 @@ private: SpinlockLocker lock(g_scheduler_lock); { { - auto array = TRY(json.add_array("processes")); + auto array = TRY(json.add_array("processes"sv)); TRY(build_process(array, *Scheduler::colonel())); TRY(Process::all_instances().with([&](auto& processes) -> ErrorOr { for (auto& process : processes) @@ -596,8 +596,8 @@ private: } auto total_time_scheduled = Scheduler::get_total_time_scheduled(); - TRY(json.add("total_time", total_time_scheduled.total)); - TRY(json.add("total_time_kernel", total_time_scheduled.total_kernel)); + TRY(json.add("total_time"sv, total_time_scheduled.total)); + TRY(json.add("total_time_kernel"sv, total_time_scheduled.total_kernel)); } TRY(json.finish()); return {}; @@ -616,13 +616,13 @@ private: [&](Processor& proc) -> ErrorOr { auto& info = proc.info(); auto obj = TRY(array.add_object()); - TRY(obj.add("processor", proc.id())); - TRY(obj.add("vendor_id", info.vendor_id_string())); - TRY(obj.add("family", info.display_family())); + TRY(obj.add("processor"sv, proc.id())); + TRY(obj.add("vendor_id"sv, info.vendor_id_string())); + TRY(obj.add("family"sv, info.display_family())); if (!info.hypervisor_vendor_id_string().is_null()) - TRY(obj.add("hypervisor_vendor_id", info.hypervisor_vendor_id_string())); + TRY(obj.add("hypervisor_vendor_id"sv, info.hypervisor_vendor_id_string())); - auto features_array = TRY(obj.add_array("features")); + auto features_array = TRY(obj.add_array("features"sv)); auto keep_empty = false; ErrorOr result; // FIXME: Make this nicer @@ -635,29 +635,29 @@ private: TRY(features_array.finish()); - TRY(obj.add("model", info.display_model())); - TRY(obj.add("stepping", info.stepping())); - TRY(obj.add("type", info.type())); - TRY(obj.add("brand", info.brand_string())); + TRY(obj.add("model"sv, info.display_model())); + TRY(obj.add("stepping"sv, info.stepping())); + TRY(obj.add("type"sv, info.type())); + TRY(obj.add("brand"sv, info.brand_string())); - auto caches = TRY(obj.add_object("caches")); + auto caches = TRY(obj.add_object("caches"sv)); auto add_cache_info = [&](StringView name, ProcessorInfo::Cache const& cache) -> ErrorOr { auto cache_object = TRY(caches.add_object(name)); - TRY(cache_object.add("size", cache.size)); - TRY(cache_object.add("line_size", cache.line_size)); + TRY(cache_object.add("size"sv, cache.size)); + TRY(cache_object.add("line_size"sv, cache.line_size)); TRY(cache_object.finish()); return {}; }; if (info.l1_data_cache().has_value()) - TRY(add_cache_info("l1_data", *info.l1_data_cache())); + TRY(add_cache_info("l1_data"sv, *info.l1_data_cache())); if (info.l1_data_cache().has_value()) - TRY(add_cache_info("l1_instruction", *info.l1_instruction_cache())); + TRY(add_cache_info("l1_instruction"sv, *info.l1_instruction_cache())); if (info.l1_data_cache().has_value()) - TRY(add_cache_info("l2", *info.l2_cache())); + TRY(add_cache_info("l2"sv, *info.l2_cache())); if (info.l1_data_cache().has_value()) - TRY(add_cache_info("l3", *info.l3_cache())); + TRY(add_cache_info("l3"sv, *info.l3_cache())); TRY(caches.finish()); @@ -701,12 +701,12 @@ private: return; result = ([&]() -> ErrorOr { auto obj = TRY(array.add_object()); - TRY(obj.add("purpose", handler.purpose())); - TRY(obj.add("interrupt_line", handler.interrupt_number())); - TRY(obj.add("controller", handler.controller())); - TRY(obj.add("cpu_handler", 0)); // FIXME: Determine the responsible CPU for each interrupt handler. - TRY(obj.add("device_sharing", (unsigned)handler.sharing_devices_count())); - TRY(obj.add("call_count", (unsigned)handler.get_invoking_count())); + TRY(obj.add("purpose"sv, handler.purpose())); + TRY(obj.add("interrupt_line"sv, handler.interrupt_number())); + TRY(obj.add("controller"sv, handler.controller())); + TRY(obj.add("cpu_handler"sv, 0)); // FIXME: Determine the responsible CPU for each interrupt handler. + TRY(obj.add("device_sharing"sv, (unsigned)handler.sharing_devices_count())); + TRY(obj.add("call_count"sv, (unsigned)handler.get_invoking_count())); TRY(obj.finish()); return {}; })(); @@ -726,7 +726,7 @@ private: { auto json = TRY(JsonObjectSerializer<>::try_create(builder)); TRY(HIDManagement::the().keymap_data().with([&](auto const& keymap_data) { - return json.add("keymap", keymap_data.character_map_name->view()); + return json.add("keymap"sv, keymap_data.character_map_name->view()); })); TRY(json.finish()); return {}; @@ -749,17 +749,17 @@ private: return; result = ([&]() -> ErrorOr { auto obj = TRY(array.add_object()); - TRY(obj.add("domain", device_identifier.address().domain())); - TRY(obj.add("bus", device_identifier.address().bus())); - TRY(obj.add("device", device_identifier.address().device())); - TRY(obj.add("function", device_identifier.address().function())); - TRY(obj.add("vendor_id", device_identifier.hardware_id().vendor_id)); - TRY(obj.add("device_id", device_identifier.hardware_id().device_id)); - TRY(obj.add("revision_id", device_identifier.revision_id().value())); - TRY(obj.add("subclass", device_identifier.subclass_code().value())); - TRY(obj.add("class", device_identifier.class_code().value())); - TRY(obj.add("subsystem_id", device_identifier.subsystem_id().value())); - TRY(obj.add("subsystem_vendor_id", device_identifier.subsystem_vendor_id().value())); + TRY(obj.add("domain"sv, device_identifier.address().domain())); + TRY(obj.add("bus"sv, device_identifier.address().bus())); + TRY(obj.add("device"sv, device_identifier.address().device())); + TRY(obj.add("function"sv, device_identifier.address().function())); + TRY(obj.add("vendor_id"sv, device_identifier.hardware_id().vendor_id)); + TRY(obj.add("device_id"sv, device_identifier.hardware_id().device_id)); + TRY(obj.add("revision_id"sv, device_identifier.revision_id().value())); + TRY(obj.add("subclass"sv, device_identifier.subclass_code().value())); + TRY(obj.add("class"sv, device_identifier.class_code().value())); + TRY(obj.add("subsystem_id"sv, device_identifier.subsystem_id().value())); + TRY(obj.add("subsystem_vendor_id"sv, device_identifier.subsystem_vendor_id().value())); TRY(obj.finish()); return {}; })(); @@ -781,14 +781,14 @@ private: auto array = TRY(JsonArraySerializer<>::try_create(builder)); TRY(DeviceManagement::the().try_for_each([&array](auto& device) -> ErrorOr { auto obj = TRY(array.add_object()); - TRY(obj.add("major", device.major().value())); - TRY(obj.add("minor", device.minor().value())); - TRY(obj.add("class_name", device.class_name())); + TRY(obj.add("major"sv, device.major().value())); + TRY(obj.add("minor"sv, device.minor().value())); + TRY(obj.add("class_name"sv, device.class_name())); if (device.is_block_device()) - TRY(obj.add("type", "block")); + TRY(obj.add("type"sv, "block")); else if (device.is_character_device()) - TRY(obj.add("type", "character")); + TRY(obj.add("type"sv, "character")); else VERIFY_NOT_REACHED(); TRY(obj.finish()); @@ -1048,8 +1048,8 @@ UNMAP_AFTER_INIT NonnullRefPtr ProcFSRootDirectory::must_cr ErrorOr ProcFSRootDirectory::traverse_as_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { MutexLocker locker(ProcFSComponentRegistry::the().get_lock()); - TRY(callback({ ".", { fsid, component_index() }, 0 })); - TRY(callback({ "..", { fsid, 0 }, 0 })); + TRY(callback({ "."sv, { fsid, component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, 0 }, 0 })); for (auto const& component : m_components) { InodeIdentifier identifier = { fsid, component.component_index() }; diff --git a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp index 0b9cc6730f9..ab252d39ef0 100644 --- a/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp +++ b/Kernel/Graphics/Console/ContiguousFramebufferConsole.cpp @@ -29,7 +29,7 @@ void ContiguousFramebufferConsole::set_resolution(size_t width, size_t height, s size_t size = Memory::page_round_up(pitch * height).release_value_but_fixme_should_propagate_errors(); dbgln("Framebuffer Console: taking {} bytes", size); - auto region_or_error = MM.allocate_kernel_region(m_framebuffer_address, size, "Framebuffer Console", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::Yes); + auto region_or_error = MM.allocate_kernel_region(m_framebuffer_address, size, "Framebuffer Console"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::Yes); VERIFY(!region_or_error.is_error()); m_framebuffer_region = region_or_error.release_value(); diff --git a/Kernel/Graphics/Console/VGAConsole.cpp b/Kernel/Graphics/Console/VGAConsole.cpp index 01741ef608f..c60a1be4939 100644 --- a/Kernel/Graphics/Console/VGAConsole.cpp +++ b/Kernel/Graphics/Console/VGAConsole.cpp @@ -11,7 +11,7 @@ namespace Kernel::Graphics { UNMAP_AFTER_INIT VGAConsole::VGAConsole(Mode mode, size_t width, size_t height) : Console(width, height) - , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000).release_value_but_fixme_should_propagate_errors(), "VGA Display", Memory::Region::Access::ReadWrite).release_value()) + , m_vga_region(MM.allocate_kernel_region(PhysicalAddress(0xa0000), Memory::page_round_up(0xc0000 - 0xa0000).release_value_but_fixme_should_propagate_errors(), "VGA Display"sv, Memory::Region::Access::ReadWrite).release_value()) , m_mode(mode) { } diff --git a/Kernel/Graphics/DisplayConnector.cpp b/Kernel/Graphics/DisplayConnector.cpp index 88ccc14d7ce..e6462e33d11 100644 --- a/Kernel/Graphics/DisplayConnector.cpp +++ b/Kernel/Graphics/DisplayConnector.cpp @@ -39,7 +39,7 @@ ErrorOr DisplayConnector::mmap(Process& process, OpenFileDescri range, *m_shared_framebuffer_vmobject, 0, - "Mapped Framebuffer", + "Mapped Framebuffer"sv, prot, shared); } diff --git a/Kernel/Graphics/Intel/NativeDisplayConnector.cpp b/Kernel/Graphics/Intel/NativeDisplayConnector.cpp index 4f4470e116b..c0b1e85c057 100644 --- a/Kernel/Graphics/Intel/NativeDisplayConnector.cpp +++ b/Kernel/Graphics/Intel/NativeDisplayConnector.cpp @@ -177,7 +177,7 @@ Optional IntelNativeDisplayConnector::create_pll_set NonnullRefPtr IntelNativeDisplayConnector::must_create(PhysicalAddress framebuffer_address, size_t framebuffer_resource_size, PhysicalAddress registers_region_address, size_t registers_region_length) { - auto registers_region = MUST(MM.allocate_kernel_region(PhysicalAddress(registers_region_address), registers_region_length, "Intel Native Graphics Registers", Memory::Region::Access::ReadWrite)); + auto registers_region = MUST(MM.allocate_kernel_region(PhysicalAddress(registers_region_address), registers_region_length, "Intel Native Graphics Registers"sv, Memory::Region::Access::ReadWrite)); auto device_or_error = DeviceManagement::try_create_device(framebuffer_address, framebuffer_resource_size, move(registers_region)); VERIFY(!device_or_error.is_error()); auto connector = device_or_error.release_value(); diff --git a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp index 7405c3ecd7c..acc93f5e5aa 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.cpp @@ -26,7 +26,7 @@ NonnullRefPtr VirtIOGPU3DDevice::must_create(VirtIOGraphicsAd // Setup memory transfer region auto region_result = MM.allocate_kernel_region( NUM_TRANSFER_REGION_PAGES * PAGE_SIZE, - "VIRGL3D kernel upload buffer", + "VIRGL3D kernel upload buffer"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow); VERIFY(!region_result.is_error()); diff --git a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h index 45f6cf84117..a59641a79ed 100644 --- a/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h +++ b/Kernel/Graphics/VirtIOGPU/GPU3DDevice.h @@ -106,7 +106,7 @@ private: { auto region_result = TRY(MM.allocate_kernel_region( NUM_TRANSFER_REGION_PAGES * PAGE_SIZE, - "VIRGL3D userspace upload buffer", + "VIRGL3D userspace upload buffer"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow)); return TRY(adopt_nonnull_ref_or_enomem(new (nothrow) PerContextState(context_id, move(region_result)))); @@ -125,7 +125,7 @@ private: virtual bool can_write(OpenFileDescription const&, u64) const override { return true; } virtual ErrorOr read(OpenFileDescription&, u64, UserOrKernelBuffer&, size_t) override { return ENOTSUP; } virtual ErrorOr write(OpenFileDescription&, u64, UserOrKernelBuffer const&, size_t) override { return ENOTSUP; } - virtual StringView class_name() const override { return "virgl3d"; } + virtual StringView class_name() const override { return "virgl3d"sv; } virtual ErrorOr ioctl(OpenFileDescription&, unsigned request, Userspace arg) override; virtual void detach(OpenFileDescription&) override; diff --git a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp index 9fb10831640..c69b6fed3ac 100644 --- a/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp +++ b/Kernel/Graphics/VirtIOGPU/GraphicsAdapter.cpp @@ -27,7 +27,7 @@ NonnullRefPtr VirtIOGraphicsAdapter::initialize(PCI::Devi // Setup memory transfer region auto scratch_space_region = MUST(MM.allocate_contiguous_kernel_region( 32 * PAGE_SIZE, - "VirtGPU Scratch Space", + "VirtGPU Scratch Space"sv, Memory::Region::Access::ReadWrite)); auto adapter = adopt_ref(*new (nothrow) VirtIOGraphicsAdapter(device_identifier, move(scratch_space_region))); diff --git a/Kernel/Interrupts/APIC.cpp b/Kernel/Interrupts/APIC.cpp index f66e9bf8110..758ba5cd378 100644 --- a/Kernel/Interrupts/APIC.cpp +++ b/Kernel/Interrupts/APIC.cpp @@ -271,7 +271,7 @@ UNMAP_AFTER_INIT bool APIC::init_bsp() dbgln("APIC: RSDP not found"); return false; } - auto madt_address = ACPI::StaticParsing::find_table(rsdp.value(), "APIC"); + auto madt_address = ACPI::StaticParsing::find_table(rsdp.value(), "APIC"sv); if (!madt_address.has_value()) { dbgln("APIC: MADT table not found"); return false; diff --git a/Kernel/Interrupts/SpuriousInterruptHandler.cpp b/Kernel/Interrupts/SpuriousInterruptHandler.cpp index f67790fbfdf..51fd499c75e 100644 --- a/Kernel/Interrupts/SpuriousInterruptHandler.cpp +++ b/Kernel/Interrupts/SpuriousInterruptHandler.cpp @@ -110,7 +110,7 @@ void SpuriousInterruptHandler::disable_interrupt_vector() StringView SpuriousInterruptHandler::controller() const { if (m_responsible_irq_controller->type() == IRQControllerType::i82093AA) - return ""; + return ""sv; return m_responsible_irq_controller->model(); } } diff --git a/Kernel/KBufferBuilder.cpp b/Kernel/KBufferBuilder.cpp index 50bf6640d6c..0f1912bad3f 100644 --- a/Kernel/KBufferBuilder.cpp +++ b/Kernel/KBufferBuilder.cpp @@ -105,19 +105,19 @@ ErrorOr KBufferBuilder::append_escaped_for_json(StringView string) for (auto ch : string) { switch (ch) { case '\b': - TRY(append("\\b")); + TRY(append("\\b"sv)); break; case '\n': - TRY(append("\\n")); + TRY(append("\\n"sv)); break; case '\t': - TRY(append("\\t")); + TRY(append("\\t"sv)); break; case '\"': - TRY(append("\\\"")); + TRY(append("\\\""sv)); break; case '\\': - TRY(append("\\\\")); + TRY(append("\\\\"sv)); break; default: if (ch >= 0 && ch <= 0x1f) diff --git a/Kernel/KLexicalPath.cpp b/Kernel/KLexicalPath.cpp index ee5cd22771b..085cfbe7714 100644 --- a/Kernel/KLexicalPath.cpp +++ b/Kernel/KLexicalPath.cpp @@ -25,7 +25,7 @@ bool is_canonical(StringView path) return false; if (path.starts_with("./"sv) || path.contains("/./"sv) || path.ends_with("/."sv)) return false; - if (path.starts_with("../"sv) || path.contains("/../"sv) || path.ends_with("/..")) + if (path.starts_with("../"sv) || path.contains("/../"sv) || path.ends_with("/.."sv)) return false; if (path.contains("//"sv)) return false; diff --git a/Kernel/Memory/MemoryManager.cpp b/Kernel/Memory/MemoryManager.cpp index a1dc009e24c..31de498efe6 100644 --- a/Kernel/Memory/MemoryManager.cpp +++ b/Kernel/Memory/MemoryManager.cpp @@ -986,7 +986,7 @@ ErrorOr> MemoryManager::allocate_contiguous_us auto physical_pages = physical_region.take_contiguous_free_pages(page_count); if (!physical_pages.is_empty()) { { - auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * page_count, "MemoryManager Allocation Sanitization", Region::Access::Read | Region::Access::Write)); + auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * page_count, "MemoryManager Allocation Sanitization"sv, Region::Access::Read | Region::Access::Write)); memset(cleanup_region->vaddr().as_ptr(), 0, PAGE_SIZE * page_count); } m_system_memory_info.user_physical_pages_uncommitted -= page_count; @@ -1012,7 +1012,7 @@ ErrorOr> MemoryManager::allocate_contiguous_su } { - auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * count, "MemoryManager Allocation Sanitization", Region::Access::Read | Region::Access::Write)); + auto cleanup_region = TRY(MM.allocate_kernel_region(physical_pages[0].paddr(), PAGE_SIZE * count, "MemoryManager Allocation Sanitization"sv, Region::Access::Read | Region::Access::Write)); memset(cleanup_region->vaddr().as_ptr(), 0, PAGE_SIZE * count); } m_system_memory_info.super_physical_pages_used += count; diff --git a/Kernel/Memory/MemoryManager.h b/Kernel/Memory/MemoryManager.h index a7eebf530f5..3072fc0c3cd 100644 --- a/Kernel/Memory/MemoryManager.h +++ b/Kernel/Memory/MemoryManager.h @@ -51,10 +51,10 @@ enum class UsedMemoryRangeType { }; static constexpr StringView UserMemoryRangeTypeNames[] { - "Low memory", - "Kernel", - "Boot module", - "Physical Pages" + "Low memory"sv, + "Kernel"sv, + "Boot module"sv, + "Physical Pages"sv }; static_assert(array_size(UserMemoryRangeTypeNames) == to_underlying(UsedMemoryRangeType::__Count)); diff --git a/Kernel/Memory/ScatterGatherList.cpp b/Kernel/Memory/ScatterGatherList.cpp index b55672d6fcc..0b22f12f6fc 100644 --- a/Kernel/Memory/ScatterGatherList.cpp +++ b/Kernel/Memory/ScatterGatherList.cpp @@ -21,7 +21,7 @@ RefPtr ScatterGatherList::try_create(AsyncBlockDeviceRequest& ScatterGatherList::ScatterGatherList(NonnullRefPtr vm_object, AsyncBlockDeviceRequest& request, size_t device_block_size) : m_vm_object(move(vm_object)) { - auto region_or_error = MM.allocate_kernel_region_with_vmobject(m_vm_object, page_round_up((request.block_count() * device_block_size)).release_value_but_fixme_should_propagate_errors(), "AHCI Scattered DMA", Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes); + auto region_or_error = MM.allocate_kernel_region_with_vmobject(m_vm_object, page_round_up((request.block_count() * device_block_size)).release_value_but_fixme_should_propagate_errors(), "AHCI Scattered DMA"sv, Region::Access::Read | Region::Access::Write, Region::Cacheable::Yes); if (region_or_error.is_error()) TODO(); m_dma_region = region_or_error.release_value(); diff --git a/Kernel/Memory/VirtualRange.h b/Kernel/Memory/VirtualRange.h index 071f78bb371..bf3d5372011 100644 --- a/Kernel/Memory/VirtualRange.h +++ b/Kernel/Memory/VirtualRange.h @@ -64,6 +64,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Kernel::Memory::VirtualRange value) { - return Formatter::format(builder, "{} - {} (size {:p})", value.base().as_ptr(), value.base().offset(value.size() - 1).as_ptr(), value.size()); + return Formatter::format(builder, "{} - {} (size {:p})"sv, value.base().as_ptr(), value.base().offset(value.size() - 1).as_ptr(), value.size()); } }; diff --git a/Kernel/Net/IPv4Socket.cpp b/Kernel/Net/IPv4Socket.cpp index 67dd1ea1fe4..497fdc49d1d 100644 --- a/Kernel/Net/IPv4Socket.cpp +++ b/Kernel/Net/IPv4Socket.cpp @@ -474,7 +474,7 @@ ErrorOr> IPv4Socket::pseudo_path(OpenFileDescription cons return KString::try_create("socket"sv); StringBuilder builder; - TRY(builder.try_append("socket:")); + TRY(builder.try_append("socket:"sv)); TRY(builder.try_appendff("{}:{}", m_local_address.to_string(), m_local_port)); if (m_role == Role::Accepted || m_role == Role::Connected) @@ -482,16 +482,16 @@ ErrorOr> IPv4Socket::pseudo_path(OpenFileDescription cons switch (m_role) { case Role::Listener: - TRY(builder.try_append(" (listening)")); + TRY(builder.try_append(" (listening)"sv)); break; case Role::Accepted: - TRY(builder.try_append(" (accepted)")); + TRY(builder.try_append(" (accepted)"sv)); break; case Role::Connected: - TRY(builder.try_append(" (connected)")); + TRY(builder.try_append(" (connected)"sv)); break; case Role::Connecting: - TRY(builder.try_append(" (connecting)")); + TRY(builder.try_append(" (connecting)"sv)); break; default: VERIFY_NOT_REACHED(); diff --git a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp index 7d0f2cfb709..7b9ee770be4 100644 --- a/Kernel/Net/Intel/E1000ENetworkAdapter.cpp +++ b/Kernel/Net/Intel/E1000ENetworkAdapter.cpp @@ -209,7 +209,7 @@ UNMAP_AFTER_INIT bool E1000ENetworkAdapter::initialize() enable_bus_mastering(pci_address()); size_t mmio_base_size = PCI::get_BAR_space_size(pci_address(), 0); - auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size).release_value_but_fixme_should_propagate_errors(), "E1000e MMIO", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); + auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size).release_value_but_fixme_should_propagate_errors(), "E1000e MMIO"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); if (region_or_error.is_error()) return false; m_mmio_region = region_or_error.release_value(); diff --git a/Kernel/Net/Intel/E1000NetworkAdapter.cpp b/Kernel/Net/Intel/E1000NetworkAdapter.cpp index e0ca57a69db..08bbbcf5843 100644 --- a/Kernel/Net/Intel/E1000NetworkAdapter.cpp +++ b/Kernel/Net/Intel/E1000NetworkAdapter.cpp @@ -200,7 +200,7 @@ UNMAP_AFTER_INIT bool E1000NetworkAdapter::initialize() m_io_base = IOAddress(PCI::get_BAR1(pci_address()) & ~1); size_t mmio_base_size = PCI::get_BAR_space_size(pci_address(), 0); - auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size).release_value_but_fixme_should_propagate_errors(), "E1000 MMIO", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); + auto region_or_error = MM.allocate_kernel_region(PhysicalAddress(page_base_of(PCI::get_BAR0(pci_address()))), Memory::page_round_up(mmio_base_size).release_value_but_fixme_should_propagate_errors(), "E1000 MMIO"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No); if (region_or_error.is_error()) return false; m_mmio_region = region_or_error.release_value(); @@ -231,8 +231,8 @@ UNMAP_AFTER_INIT E1000NetworkAdapter::E1000NetworkAdapter(PCI::Address address, : NetworkAdapter(move(interface_name)) , PCI::Device(address) , IRQHandler(irq) - , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 RX Descriptors", Memory::Region::Access::ReadWrite).release_value()) - , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 TX Descriptors", Memory::Region::Access::ReadWrite).release_value()) + , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_rx_desc) * number_of_rx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 RX Descriptors"sv, Memory::Region::Access::ReadWrite).release_value()) + , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(e1000_tx_desc) * number_of_tx_descriptors).release_value_but_fixme_should_propagate_errors(), "E1000 TX Descriptors"sv, Memory::Region::Access::ReadWrite).release_value()) { } @@ -324,7 +324,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_rx_descriptors() constexpr auto rx_buffer_size = 8192; constexpr auto rx_buffer_page_count = rx_buffer_size / PAGE_SIZE; - m_rx_buffer_region = MM.allocate_contiguous_kernel_region(rx_buffer_size * number_of_rx_descriptors, "E1000 RX buffers", Memory::Region::Access::ReadWrite).release_value(); + m_rx_buffer_region = MM.allocate_contiguous_kernel_region(rx_buffer_size * number_of_rx_descriptors, "E1000 RX buffers"sv, Memory::Region::Access::ReadWrite).release_value(); for (size_t i = 0; i < number_of_rx_descriptors; ++i) { auto& descriptor = rx_descriptors[i]; m_rx_buffers[i] = m_rx_buffer_region->vaddr().as_ptr() + rx_buffer_size * i; @@ -347,7 +347,7 @@ UNMAP_AFTER_INIT void E1000NetworkAdapter::initialize_tx_descriptors() constexpr auto tx_buffer_size = 8192; constexpr auto tx_buffer_page_count = tx_buffer_size / PAGE_SIZE; - m_tx_buffer_region = MM.allocate_contiguous_kernel_region(tx_buffer_size * number_of_tx_descriptors, "E1000 TX buffers", Memory::Region::Access::ReadWrite).release_value(); + m_tx_buffer_region = MM.allocate_contiguous_kernel_region(tx_buffer_size * number_of_tx_descriptors, "E1000 TX buffers"sv, Memory::Region::Access::ReadWrite).release_value(); for (size_t i = 0; i < number_of_tx_descriptors; ++i) { auto& descriptor = tx_descriptors[i]; @@ -446,7 +446,7 @@ void E1000NetworkAdapter::send_raw(ReadonlyBytes payload) sti(); break; } - m_wait_queue.wait_forever("E1000NetworkAdapter"); + m_wait_queue.wait_forever("E1000NetworkAdapter"sv); } dbgln_if(E1000_DEBUG, "E1000: Sent packet, status is now {:#02x}!", (u8)descriptor.status); } diff --git a/Kernel/Net/LocalSocket.cpp b/Kernel/Net/LocalSocket.cpp index 04fbca624cf..71c1a1b7f81 100644 --- a/Kernel/Net/LocalSocket.cpp +++ b/Kernel/Net/LocalSocket.cpp @@ -368,12 +368,12 @@ StringView LocalSocket::socket_path() const ErrorOr> LocalSocket::pseudo_path(OpenFileDescription const& description) const { StringBuilder builder; - TRY(builder.try_append("socket:")); + TRY(builder.try_append("socket:"sv)); TRY(builder.try_append(socket_path())); switch (role(description)) { case Role::Listener: - TRY(builder.try_append(" (listening)")); + TRY(builder.try_append(" (listening)"sv)); break; case Role::Accepted: TRY(builder.try_appendff(" (accepted from pid {})", origin_pid())); @@ -382,7 +382,7 @@ ErrorOr> LocalSocket::pseudo_path(OpenFileDescription con TRY(builder.try_appendff(" (connected to pid {})", acceptor_pid())); break; case Role::Connecting: - TRY(builder.try_append(" (connecting)")); + TRY(builder.try_append(" (connecting)"sv)); break; default: break; diff --git a/Kernel/Net/NE2000/NetworkAdapter.cpp b/Kernel/Net/NE2000/NetworkAdapter.cpp index 1cc1ef25e99..a3cf68d1be2 100644 --- a/Kernel/Net/NE2000/NetworkAdapter.cpp +++ b/Kernel/Net/NE2000/NetworkAdapter.cpp @@ -379,7 +379,7 @@ void NE2000NetworkAdapter::send_raw(ReadonlyBytes payload) } while (in8(REG_RW_COMMAND) & BIT_COMMAND_TXP) - m_wait_queue.wait_forever("NE2000NetworkAdapter"); + m_wait_queue.wait_forever("NE2000NetworkAdapter"sv); disable_irq(); size_t packet_size = payload.size(); diff --git a/Kernel/Net/NetworkTask.cpp b/Kernel/Net/NetworkTask.cpp index 632ca05beb6..722241b9b34 100644 --- a/Kernel/Net/NetworkTask.cpp +++ b/Kernel/Net/NetworkTask.cpp @@ -43,7 +43,7 @@ static HashTable>* delayed_ack_sockets; void NetworkTask::spawn() { RefPtr thread; - auto name = KString::try_create("Network Task"); + auto name = KString::try_create("Network Task"sv); if (name.is_error()) TODO(); (void)Process::create_kernel_process(thread, name.release_value(), NetworkTask_main, nullptr); @@ -90,7 +90,7 @@ void NetworkTask_main(void*) }; size_t buffer_size = 64 * KiB; - auto region_or_error = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer", Memory::Region::Access::ReadWrite); + auto region_or_error = MM.allocate_kernel_region(buffer_size, "Kernel Packet Buffer"sv, Memory::Region::Access::ReadWrite); if (region_or_error.is_error()) TODO(); auto buffer_region = region_or_error.release_value(); @@ -104,7 +104,7 @@ void NetworkTask_main(void*) if (!packet_size) { auto timeout_time = Time::from_milliseconds(500); auto timeout = Thread::BlockTimeout { false, &timeout_time }; - [[maybe_unused]] auto result = packet_wait_queue.wait_on(timeout, "NetworkTask"); + [[maybe_unused]] auto result = packet_wait_queue.wait_on(timeout, "NetworkTask"sv); continue; } if (packet_size < sizeof(EthernetFrameHeader)) { diff --git a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp index 6481280a750..038464fd835 100644 --- a/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp +++ b/Kernel/Net/Realtek/RTL8139NetworkAdapter.cpp @@ -131,8 +131,8 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre , PCI::Device(address) , IRQHandler(irq) , m_io_base(PCI::get_BAR0(pci_address()) & ~1) - , m_rx_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX).release_value_but_fixme_should_propagate_errors(), "RTL8139 RX", Memory::Region::Access::ReadWrite).release_value()) - , m_packet_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(PACKET_SIZE_MAX).release_value_but_fixme_should_propagate_errors(), "RTL8139 Packet buffer", Memory::Region::Access::ReadWrite).release_value()) + , m_rx_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE + PACKET_SIZE_MAX).release_value_but_fixme_should_propagate_errors(), "RTL8139 RX"sv, Memory::Region::Access::ReadWrite).release_value()) + , m_packet_buffer(MM.allocate_contiguous_kernel_region(Memory::page_round_up(PACKET_SIZE_MAX).release_value_but_fixme_should_propagate_errors(), "RTL8139 Packet buffer"sv, Memory::Region::Access::ReadWrite).release_value()) { m_tx_buffers.ensure_capacity(RTL8139_TX_BUFFER_COUNT); @@ -149,7 +149,7 @@ UNMAP_AFTER_INIT RTL8139NetworkAdapter::RTL8139NetworkAdapter(PCI::Address addre dbgln("RTL8139: RX buffer: {}", m_rx_buffer->physical_page(0)->paddr()); for (int i = 0; i < RTL8139_TX_BUFFER_COUNT; i++) { - m_tx_buffers.append(MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8139 TX", Memory::Region::Access::Write | Memory::Region::Access::Read).release_value()); + m_tx_buffers.append(MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8139 TX"sv, Memory::Region::Access::Write | Memory::Region::Access::Read).release_value()); dbgln("RTL8139: TX buffer {}: {}", i, m_tx_buffers[i]->physical_page(0)->paddr()); } diff --git a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp index 0d1fcc39450..4d3f52511d3 100644 --- a/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp +++ b/Kernel/Net/Realtek/RTL8168NetworkAdapter.cpp @@ -246,8 +246,8 @@ UNMAP_AFTER_INIT RTL8168NetworkAdapter::RTL8168NetworkAdapter(PCI::Address addre , PCI::Device(address) , IRQHandler(irq) , m_io_base(PCI::get_BAR0(pci_address()) & ~1) - , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX", Memory::Region::Access::ReadWrite).release_value()) - , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX", Memory::Region::Access::ReadWrite).release_value()) + , m_rx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(TXDescriptor) * (number_of_rx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX"sv, Memory::Region::Access::ReadWrite).release_value()) + , m_tx_descriptors_region(MM.allocate_contiguous_kernel_region(Memory::page_round_up(sizeof(RXDescriptor) * (number_of_tx_descriptors + 1)).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX"sv, Memory::Region::Access::ReadWrite).release_value()) { dmesgln("RTL8168: Found @ {}", pci_address()); dmesgln("RTL8168: I/O port base: {}", m_io_base); @@ -1095,7 +1095,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_rx_descriptors() auto* rx_descriptors = (RXDescriptor*)m_rx_descriptors_region->vaddr().as_ptr(); for (size_t i = 0; i < number_of_rx_descriptors; ++i) { auto& descriptor = rx_descriptors[i]; - auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX buffer", Memory::Region::Access::ReadWrite).release_value(); + auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(RX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 RX buffer"sv, Memory::Region::Access::ReadWrite).release_value(); memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes m_rx_buffers_regions.append(move(region)); @@ -1113,7 +1113,7 @@ UNMAP_AFTER_INIT void RTL8168NetworkAdapter::initialize_tx_descriptors() auto* tx_descriptors = (TXDescriptor*)m_tx_descriptors_region->vaddr().as_ptr(); for (size_t i = 0; i < number_of_tx_descriptors; ++i) { auto& descriptor = tx_descriptors[i]; - auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX buffer", Memory::Region::Access::ReadWrite).release_value(); + auto region = MM.allocate_contiguous_kernel_region(Memory::page_round_up(TX_BUFFER_SIZE).release_value_but_fixme_should_propagate_errors(), "RTL8168 TX buffer"sv, Memory::Region::Access::ReadWrite).release_value(); memset(region->vaddr().as_ptr(), 0, region->size()); // MM already zeros out newly allocated pages, but we do it again in case that ever changes m_tx_buffers_regions.append(move(region)); @@ -1204,7 +1204,7 @@ void RTL8168NetworkAdapter::send_raw(ReadonlyBytes payload) if ((free_descriptor.flags & TXDescriptor::Ownership) != 0) { dbgln_if(RTL8168_DEBUG, "RTL8168: No free TX buffers, sleeping until one is available"); - m_wait_queue.wait_forever("RTL8168NetworkAdapter"); + m_wait_queue.wait_forever("RTL8168NetworkAdapter"sv); return send_raw(payload); // if we woke up a TX descriptor is guaranteed to be available, so this should never recurse more than once // but this can probably be done more cleanly @@ -1664,7 +1664,7 @@ StringView RTL8168NetworkAdapter::possible_device_name() case ChipVersion::Version19: return "RTL8168F/8111F"sv; // 35, 36 case ChipVersion::Version20: - return "RTL8411"; // 38 + return "RTL8411"sv; // 38 case ChipVersion::Version21: case ChipVersion::Version22: return "RTL8168G/8111G"sv; // 40, 41, 42 @@ -1676,7 +1676,7 @@ StringView RTL8168NetworkAdapter::possible_device_name() case ChipVersion::Version25: return "RTL8168GU/8111GU"sv; // ??? case ChipVersion::Version26: - return "RTL8411B"; // 44 + return "RTL8411B"sv; // 44 case ChipVersion::Version29: case ChipVersion::Version30: return "RTL8168H/8111H"sv; // 45, 46 diff --git a/Kernel/Net/TCPSocket.h b/Kernel/Net/TCPSocket.h index e9d588b790f..8f7530214e0 100644 --- a/Kernel/Net/TCPSocket.h +++ b/Kernel/Net/TCPSocket.h @@ -88,7 +88,7 @@ public: case State::TimeWait: return "TimeWait"sv; default: - return "None"; + return "None"sv; } } diff --git a/Kernel/PerformanceEventBuffer.cpp b/Kernel/PerformanceEventBuffer.cpp index 1920a48facc..50ee253202f 100644 --- a/Kernel/PerformanceEventBuffer.cpp +++ b/Kernel/PerformanceEventBuffer.cpp @@ -191,7 +191,7 @@ template ErrorOr PerformanceEventBuffer::to_json_impl(Serializer& object) const { { - auto strings = TRY(object.add_array("strings")); + auto strings = TRY(object.add_array("strings"sv)); Vector strings_sorted_by_index; TRY(strings_sorted_by_index.try_resize(m_strings.size())); @@ -207,7 +207,7 @@ ErrorOr PerformanceEventBuffer::to_json_impl(Serializer& object) const } bool show_kernel_addresses = Process::current().is_superuser(); - auto array = TRY(object.add_array("events")); + auto array = TRY(object.add_array("events"sv)); bool seen_first_sample = false; for (size_t i = 0; i < m_count; ++i) { auto const& event = at(i); @@ -220,67 +220,67 @@ ErrorOr PerformanceEventBuffer::to_json_impl(Serializer& object) const auto event_object = TRY(array.add_object()); switch (event.type) { case PERF_EVENT_SAMPLE: - TRY(event_object.add("type", "sample")); + TRY(event_object.add("type"sv, "sample")); break; case PERF_EVENT_MALLOC: - TRY(event_object.add("type", "malloc")); - TRY(event_object.add("ptr", static_cast(event.data.malloc.ptr))); - TRY(event_object.add("size", static_cast(event.data.malloc.size))); + TRY(event_object.add("type"sv, "malloc")); + TRY(event_object.add("ptr"sv, static_cast(event.data.malloc.ptr))); + TRY(event_object.add("size"sv, static_cast(event.data.malloc.size))); break; case PERF_EVENT_FREE: - TRY(event_object.add("type", "free")); - TRY(event_object.add("ptr", static_cast(event.data.free.ptr))); + TRY(event_object.add("type"sv, "free")); + TRY(event_object.add("ptr"sv, static_cast(event.data.free.ptr))); break; case PERF_EVENT_MMAP: - TRY(event_object.add("type", "mmap")); - TRY(event_object.add("ptr", static_cast(event.data.mmap.ptr))); - TRY(event_object.add("size", static_cast(event.data.mmap.size))); - TRY(event_object.add("name", event.data.mmap.name)); + TRY(event_object.add("type"sv, "mmap")); + TRY(event_object.add("ptr"sv, static_cast(event.data.mmap.ptr))); + TRY(event_object.add("size"sv, static_cast(event.data.mmap.size))); + TRY(event_object.add("name"sv, event.data.mmap.name)); break; case PERF_EVENT_MUNMAP: - TRY(event_object.add("type", "munmap")); - TRY(event_object.add("ptr", static_cast(event.data.munmap.ptr))); - TRY(event_object.add("size", static_cast(event.data.munmap.size))); + TRY(event_object.add("type"sv, "munmap")); + TRY(event_object.add("ptr"sv, static_cast(event.data.munmap.ptr))); + TRY(event_object.add("size"sv, static_cast(event.data.munmap.size))); break; case PERF_EVENT_PROCESS_CREATE: - TRY(event_object.add("type", "process_create")); - TRY(event_object.add("parent_pid", static_cast(event.data.process_create.parent_pid))); - TRY(event_object.add("executable", event.data.process_create.executable)); + TRY(event_object.add("type"sv, "process_create")); + TRY(event_object.add("parent_pid"sv, static_cast(event.data.process_create.parent_pid))); + TRY(event_object.add("executable"sv, event.data.process_create.executable)); break; case PERF_EVENT_PROCESS_EXEC: - TRY(event_object.add("type", "process_exec")); - TRY(event_object.add("executable", event.data.process_exec.executable)); + TRY(event_object.add("type"sv, "process_exec")); + TRY(event_object.add("executable"sv, event.data.process_exec.executable)); break; case PERF_EVENT_PROCESS_EXIT: - TRY(event_object.add("type", "process_exit")); + TRY(event_object.add("type"sv, "process_exit")); break; case PERF_EVENT_THREAD_CREATE: - TRY(event_object.add("type", "thread_create")); - TRY(event_object.add("parent_tid", static_cast(event.data.thread_create.parent_tid))); + TRY(event_object.add("type"sv, "thread_create")); + TRY(event_object.add("parent_tid"sv, static_cast(event.data.thread_create.parent_tid))); break; case PERF_EVENT_THREAD_EXIT: - TRY(event_object.add("type", "thread_exit")); + TRY(event_object.add("type"sv, "thread_exit")); break; case PERF_EVENT_CONTEXT_SWITCH: - TRY(event_object.add("type", "context_switch")); - TRY(event_object.add("next_pid", static_cast(event.data.context_switch.next_pid))); - TRY(event_object.add("next_tid", static_cast(event.data.context_switch.next_tid))); + TRY(event_object.add("type"sv, "context_switch")); + TRY(event_object.add("next_pid"sv, static_cast(event.data.context_switch.next_pid))); + TRY(event_object.add("next_tid"sv, static_cast(event.data.context_switch.next_tid))); break; case PERF_EVENT_KMALLOC: - TRY(event_object.add("type", "kmalloc")); - TRY(event_object.add("ptr", static_cast(event.data.kmalloc.ptr))); - TRY(event_object.add("size", static_cast(event.data.kmalloc.size))); + TRY(event_object.add("type"sv, "kmalloc")); + TRY(event_object.add("ptr"sv, static_cast(event.data.kmalloc.ptr))); + TRY(event_object.add("size"sv, static_cast(event.data.kmalloc.size))); break; case PERF_EVENT_KFREE: - TRY(event_object.add("type", "kfree")); - TRY(event_object.add("ptr", static_cast(event.data.kfree.ptr))); - TRY(event_object.add("size", static_cast(event.data.kfree.size))); + TRY(event_object.add("type"sv, "kfree")); + TRY(event_object.add("ptr"sv, static_cast(event.data.kfree.ptr))); + TRY(event_object.add("size"sv, static_cast(event.data.kfree.size))); break; case PERF_EVENT_PAGE_FAULT: - TRY(event_object.add("type", "page_fault")); + TRY(event_object.add("type"sv, "page_fault")); break; case PERF_EVENT_SYSCALL: - TRY(event_object.add("type", "syscall")); + TRY(event_object.add("type"sv, "syscall")); break; case PERF_EVENT_SIGNPOST: TRY(event_object.add("type"sv, "signpost"sv)); @@ -288,21 +288,21 @@ ErrorOr PerformanceEventBuffer::to_json_impl(Serializer& object) const TRY(event_object.add("arg2"sv, event.data.signpost.arg2)); break; case PERF_EVENT_READ: - TRY(event_object.add("type", "read")); - TRY(event_object.add("fd", event.data.read.fd)); + TRY(event_object.add("type"sv, "read")); + TRY(event_object.add("fd"sv, event.data.read.fd)); TRY(event_object.add("size"sv, event.data.read.size)); TRY(event_object.add("filename_index"sv, event.data.read.filename_index)); TRY(event_object.add("start_timestamp"sv, event.data.read.start_timestamp)); TRY(event_object.add("success"sv, event.data.read.success)); break; } - TRY(event_object.add("pid", event.pid)); - TRY(event_object.add("tid", event.tid)); - TRY(event_object.add("timestamp", event.timestamp)); - TRY(event_object.add("lost_samples", seen_first_sample ? event.lost_samples : 0)); + TRY(event_object.add("pid"sv, event.pid)); + TRY(event_object.add("tid"sv, event.tid)); + TRY(event_object.add("timestamp"sv, event.timestamp)); + TRY(event_object.add("lost_samples"sv, seen_first_sample ? event.lost_samples : 0)); if (event.type == PERF_EVENT_SAMPLE) seen_first_sample = true; - auto stack_array = TRY(event_object.add_array("stack")); + auto stack_array = TRY(event_object.add_array("stack"sv)); for (size_t j = 0; j < event.stack_size; ++j) { auto address = event.stack[j]; if (!show_kernel_addresses && !Memory::is_user_address(VirtualAddress { address })) diff --git a/Kernel/PerformanceManager.h b/Kernel/PerformanceManager.h index a2f5d77786b..fb909c85225 100644 --- a/Kernel/PerformanceManager.h +++ b/Kernel/PerformanceManager.h @@ -149,7 +149,7 @@ public: return; filepath_string_index = registered_result.value(); } else { - auto invalid_path_string = KString::try_create(""); // TODO: Performance, unecessary allocations. + auto invalid_path_string = KString::try_create(""sv); // TODO: Performance, unecessary allocations. if (invalid_path_string.is_error()) return; auto registered_result = event_buffer->register_string(move(invalid_path_string.value())); diff --git a/Kernel/PhysicalAddress.h b/Kernel/PhysicalAddress.h index 8a4fbaef256..8610992ab5d 100644 --- a/Kernel/PhysicalAddress.h +++ b/Kernel/PhysicalAddress.h @@ -61,8 +61,8 @@ struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, PhysicalAddress value) { if constexpr (sizeof(PhysicalPtr) == sizeof(u64)) - return AK::Formatter::format(builder, "P{:016x}", value.get()); + return AK::Formatter::format(builder, "P{:016x}"sv, value.get()); else - return AK::Formatter::format(builder, "P{}", value.as_ptr()); + return AK::Formatter::format(builder, "P{}"sv, value.as_ptr()); } }; diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp index 1e911cf3b3d..4c50479e708 100644 --- a/Kernel/Process.cpp +++ b/Kernel/Process.cpp @@ -374,7 +374,7 @@ extern "C" char const asm_signal_trampoline_end[]; void create_signal_trampoline() { // NOTE: We leak this region. - g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines", Memory::Region::Access::ReadWrite).release_value().leak_ptr(); + g_signal_trampoline_region = MM.allocate_kernel_region(PAGE_SIZE, "Signal trampolines"sv, Memory::Region::Access::ReadWrite).release_value().leak_ptr(); g_signal_trampoline_region->set_syscall_region(true); size_t trampoline_size = asm_signal_trampoline_end - asm_signal_trampoline; @@ -905,7 +905,7 @@ static constexpr StringView to_string(Pledge promise) { #define __ENUMERATE_PLEDGE_PROMISE(x) \ case Pledge::x: \ - return #x; + return #x##sv; switch (promise) { ENUMERATE_PLEDGE_PROMISES } diff --git a/Kernel/Process.h b/Kernel/Process.h index 2bfa038b968..aae7df23e52 100644 --- a/Kernel/Process.h +++ b/Kernel/Process.h @@ -819,8 +819,8 @@ private: size_t m_master_tls_size { 0 }; size_t m_master_tls_alignment { 0 }; - Mutex m_big_lock { "Process", Mutex::MutexBehavior::BigLock }; - Mutex m_ptrace_lock { "ptrace" }; + Mutex m_big_lock { "Process"sv, Mutex::MutexBehavior::BigLock }; + Mutex m_ptrace_lock { "ptrace"sv }; RefPtr m_alarm_timer; @@ -1036,6 +1036,6 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, Kernel::Process const& value) { - return AK::Formatter::format(builder, "{}({})", value.name(), value.pid().value()); + return AK::Formatter::format(builder, "{}({})"sv, value.name(), value.pid().value()); } }; diff --git a/Kernel/ProcessExposed.cpp b/Kernel/ProcessExposed.cpp index 2a37d062690..e553103b37d 100644 --- a/Kernel/ProcessExposed.cpp +++ b/Kernel/ProcessExposed.cpp @@ -241,8 +241,8 @@ ErrorOr ProcFSExposedDirectory::traverse_as_directory(FileSystemID fsid, F auto parent_directory = m_parent_directory.strong_ref(); if (parent_directory.is_null()) return Error::from_errno(EINVAL); - TRY(callback({ ".", { fsid, component_index() }, DT_DIR })); - TRY(callback({ "..", { fsid, parent_directory->component_index() }, DT_DIR })); + TRY(callback({ "."sv, { fsid, component_index() }, DT_DIR })); + TRY(callback({ ".."sv, { fsid, parent_directory->component_index() }, DT_DIR })); for (auto const& component : m_components) { InodeIdentifier identifier = { fsid, component.component_index() }; diff --git a/Kernel/ProcessExposed.h b/Kernel/ProcessExposed.h index 5a15725c565..cd2edf5321b 100644 --- a/Kernel/ProcessExposed.h +++ b/Kernel/ProcessExposed.h @@ -138,7 +138,7 @@ public: protected: virtual bool acquire_link(KBufferBuilder& builder) = 0; explicit ProcFSExposedLink(StringView name); - mutable Mutex m_lock { "ProcFSLink" }; + mutable Mutex m_lock { "ProcFSLink"sv }; }; namespace PCI { diff --git a/Kernel/ProcessProcFSTraits.cpp b/Kernel/ProcessProcFSTraits.cpp index 8776a444f9e..78a04f5469a 100644 --- a/Kernel/ProcessProcFSTraits.cpp +++ b/Kernel/ProcessProcFSTraits.cpp @@ -51,19 +51,19 @@ ErrorOr Process::ProcessProcFSTraits::traverse_as_directory(FileSystemID f if (!process) return ESRCH; - TRY(callback({ ".", { fsid, SegmentedProcFSIndex::build_segmented_index_for_pid_directory(process->pid()) }, DT_DIR })); - TRY(callback({ "..", { fsid, ProcFSComponentRegistry::the().root_directory().component_index() }, DT_DIR })); - TRY(callback({ "fd", { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::OpenFileDescriptions) }, DT_DIR })); - TRY(callback({ "stacks", { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::Stacks) }, DT_DIR })); - TRY(callback({ "children", { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::Children) }, DT_DIR })); - TRY(callback({ "unveil", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::Unveil) }, DT_REG })); - TRY(callback({ "pledge", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::Pledge) }, DT_REG })); - TRY(callback({ "fds", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::OpenFileDescriptions) }, DT_DIR })); - TRY(callback({ "exe", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::BinaryLink) }, DT_LNK })); - TRY(callback({ "cwd", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::CurrentWorkDirectoryLink) }, DT_LNK })); - TRY(callback({ "perf_events", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::PerformanceEvents) }, DT_REG })); - TRY(callback({ "vm", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::VirtualMemoryStats) }, DT_REG })); - TRY(callback({ "cmdline", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::CommandLine) }, DT_REG })); + TRY(callback({ "."sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_pid_directory(process->pid()) }, DT_DIR })); + TRY(callback({ ".."sv, { fsid, ProcFSComponentRegistry::the().root_directory().component_index() }, DT_DIR })); + TRY(callback({ "fd"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::OpenFileDescriptions) }, DT_DIR })); + TRY(callback({ "stacks"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::Stacks) }, DT_DIR })); + TRY(callback({ "children"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(process->pid(), SegmentedProcFSIndex::ProcessSubDirectory::Children) }, DT_DIR })); + TRY(callback({ "unveil"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::Unveil) }, DT_REG })); + TRY(callback({ "pledge"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::Pledge) }, DT_REG })); + TRY(callback({ "fds"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::OpenFileDescriptions) }, DT_DIR })); + TRY(callback({ "exe"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::BinaryLink) }, DT_LNK })); + TRY(callback({ "cwd"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::CurrentWorkDirectoryLink) }, DT_LNK })); + TRY(callback({ "perf_events"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::PerformanceEvents) }, DT_REG })); + TRY(callback({ "vm"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::VirtualMemoryStats) }, DT_REG })); + TRY(callback({ "cmdline"sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property_in_pid_directory(process->pid(), SegmentedProcFSIndex::MainProcessProperty::CommandLine) }, DT_REG })); return {}; } diff --git a/Kernel/ProcessSpecificExposed.cpp b/Kernel/ProcessSpecificExposed.cpp index d4fd0eff8c0..14eb1db6802 100644 --- a/Kernel/ProcessSpecificExposed.cpp +++ b/Kernel/ProcessSpecificExposed.cpp @@ -43,8 +43,8 @@ ErrorOr Process::procfs_get_thread_stack(ThreadID thread_id, KBufferBuilde ErrorOr Process::traverse_stacks_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { - TRY(callback({ ".", { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property(pid(), SegmentedProcFSIndex::ProcessSubDirectory::Stacks, SegmentedProcFSIndex::MainProcessProperty::Reserved) }, 0 })); - TRY(callback({ "..", { fsid, m_procfs_traits->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_main_property(pid(), SegmentedProcFSIndex::ProcessSubDirectory::Stacks, SegmentedProcFSIndex::MainProcessProperty::Reserved) }, 0 })); + TRY(callback({ ".."sv, { fsid, m_procfs_traits->component_index() }, 0 })); return thread_list().with([&](auto& list) -> ErrorOr { for (auto const& thread : list) { @@ -82,8 +82,8 @@ ErrorOr> Process::lookup_stacks_directory(ProcFS const& pro ErrorOr Process::traverse_children_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { - TRY(callback({ ".", { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(pid(), SegmentedProcFSIndex::ProcessSubDirectory::Children) }, 0 })); - TRY(callback({ "..", { fsid, m_procfs_traits->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, SegmentedProcFSIndex::build_segmented_index_for_sub_directory(pid(), SegmentedProcFSIndex::ProcessSubDirectory::Children) }, 0 })); + TRY(callback({ ".."sv, { fsid, m_procfs_traits->component_index() }, 0 })); return Process::all_instances().with([&](auto& processes) -> ErrorOr { for (auto& process : processes) { if (process.ppid() == pid()) { @@ -126,8 +126,8 @@ ErrorOr Process::procfs_get_file_description_link(unsigned fd, KBufferBu ErrorOr Process::traverse_file_descriptions_directory(FileSystemID fsid, Function(FileSystem::DirectoryEntryView const&)> callback) const { - TRY(callback({ ".", { fsid, m_procfs_traits->component_index() }, 0 })); - TRY(callback({ "..", { fsid, m_procfs_traits->component_index() }, 0 })); + TRY(callback({ "."sv, { fsid, m_procfs_traits->component_index() }, 0 })); + TRY(callback({ ".."sv, { fsid, m_procfs_traits->component_index() }, 0 })); size_t count = 0; fds().with_shared([&](auto& fds) { fds.enumerate([&](auto& file_description_metadata) { @@ -164,12 +164,12 @@ ErrorOr Process::procfs_get_pledge_stats(KBufferBuilder& builder) const if (has_promised(Pledge::x)) { \ if (!promises_builder.is_empty()) \ TRY(promises_builder.try_append(' ')); \ - TRY(promises_builder.try_append(#x)); \ + TRY(promises_builder.try_append(#x##sv)); \ } if (has_promises()) { StringBuilder promises_builder; ENUMERATE_PLEDGE_PROMISES - TRY(obj.add("promises", promises_builder.string_view())); + TRY(obj.add("promises"sv, promises_builder.string_view())); } #undef __ENUMERATE_PLEDGE_PROMISE TRY(obj.finish()); @@ -184,7 +184,7 @@ ErrorOr Process::procfs_get_unveil_stats(KBufferBuilder& builder) const if (!unveiled_path.was_explicitly_unveiled()) return IterationDecision::Continue; auto obj = TRY(array.add_object()); - TRY(obj.add("path", unveiled_path.path())); + TRY(obj.add("path"sv, unveiled_path.path())); StringBuilder permissions_builder; if (unveiled_path.permissions() & UnveilAccess::Read) permissions_builder.append('r'); @@ -196,7 +196,7 @@ ErrorOr Process::procfs_get_unveil_stats(KBufferBuilder& builder) const permissions_builder.append('c'); if (unveiled_path.permissions() & UnveilAccess::Browse) permissions_builder.append('b'); - TRY(obj.add("permissions", permissions_builder.string_view())); + TRY(obj.add("permissions"sv, permissions_builder.string_view())); TRY(obj.finish()); return IterationDecision::Continue; })); @@ -235,22 +235,22 @@ ErrorOr Process::procfs_get_fds_stats(KBufferBuilder& builder) const bool cloexec = file_description_metadata.flags() & FD_CLOEXEC; RefPtr description = file_description_metadata.description(); auto description_object = TRY(array.add_object()); - TRY(description_object.add("fd", count)); + TRY(description_object.add("fd"sv, count)); // TODO: Better OOM handling. auto pseudo_path_or_error = description->pseudo_path(); - TRY(description_object.add("absolute_path", pseudo_path_or_error.is_error() ? "???"sv : pseudo_path_or_error.value()->view())); - TRY(description_object.add("seekable", description->file().is_seekable())); - TRY(description_object.add("class", description->file().class_name())); - TRY(description_object.add("offset", description->offset())); - TRY(description_object.add("cloexec", cloexec)); - TRY(description_object.add("blocking", description->is_blocking())); - TRY(description_object.add("can_read", description->can_read())); - TRY(description_object.add("can_write", description->can_write())); + TRY(description_object.add("absolute_path"sv, pseudo_path_or_error.is_error() ? "???"sv : pseudo_path_or_error.value()->view())); + TRY(description_object.add("seekable"sv, description->file().is_seekable())); + TRY(description_object.add("class"sv, description->file().class_name())); + TRY(description_object.add("offset"sv, description->offset())); + TRY(description_object.add("cloexec"sv, cloexec)); + TRY(description_object.add("blocking"sv, description->is_blocking())); + TRY(description_object.add("can_read"sv, description->can_read())); + TRY(description_object.add("can_write"sv, description->can_write())); Inode* inode = description->inode(); if (inode != nullptr) { - auto inode_object = TRY(description_object.add_object("inode")); - TRY(inode_object.add("fsid", inode->fsid().value())); - TRY(inode_object.add("index", inode->index().value())); + auto inode_object = TRY(description_object.add_object("inode"sv)); + TRY(inode_object.add("fsid"sv, inode->fsid().value())); + TRY(inode_object.add("index"sv, inode->index().value())); TRY(inode_object.finish()); } TRY(description_object.finish()); @@ -272,24 +272,24 @@ ErrorOr Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder) if (!region.is_user() && !Process::current().is_superuser()) continue; auto region_object = TRY(array.add_object()); - TRY(region_object.add("readable", region.is_readable())); - TRY(region_object.add("writable", region.is_writable())); - TRY(region_object.add("executable", region.is_executable())); - TRY(region_object.add("stack", region.is_stack())); - TRY(region_object.add("shared", region.is_shared())); - TRY(region_object.add("syscall", region.is_syscall_region())); - TRY(region_object.add("purgeable", region.vmobject().is_anonymous())); + TRY(region_object.add("readable"sv, region.is_readable())); + TRY(region_object.add("writable"sv, region.is_writable())); + TRY(region_object.add("executable"sv, region.is_executable())); + TRY(region_object.add("stack"sv, region.is_stack())); + TRY(region_object.add("shared"sv, region.is_shared())); + TRY(region_object.add("syscall"sv, region.is_syscall_region())); + TRY(region_object.add("purgeable"sv, region.vmobject().is_anonymous())); if (region.vmobject().is_anonymous()) { - TRY(region_object.add("volatile", static_cast(region.vmobject()).is_volatile())); + TRY(region_object.add("volatile"sv, static_cast(region.vmobject()).is_volatile())); } - TRY(region_object.add("cacheable", region.is_cacheable())); - TRY(region_object.add("address", region.vaddr().get())); - TRY(region_object.add("size", region.size())); - TRY(region_object.add("amount_resident", region.amount_resident())); - TRY(region_object.add("amount_dirty", region.amount_dirty())); - TRY(region_object.add("cow_pages", region.cow_pages())); - TRY(region_object.add("name", region.name())); - TRY(region_object.add("vmobject", region.vmobject().class_name())); + TRY(region_object.add("cacheable"sv, region.is_cacheable())); + TRY(region_object.add("address"sv, region.vaddr().get())); + TRY(region_object.add("size"sv, region.size())); + TRY(region_object.add("amount_resident"sv, region.amount_resident())); + TRY(region_object.add("amount_dirty"sv, region.amount_dirty())); + TRY(region_object.add("cow_pages"sv, region.cow_pages())); + TRY(region_object.add("name"sv, region.name())); + TRY(region_object.add("vmobject"sv, region.vmobject().class_name())); StringBuilder pagemap_builder; for (size_t i = 0; i < region.page_count(); ++i) { @@ -301,7 +301,7 @@ ErrorOr Process::procfs_get_virtual_memory_stats(KBufferBuilder& builder) else pagemap_builder.append('P'); } - TRY(region_object.add("pagemap", pagemap_builder.string_view())); + TRY(region_object.add("pagemap"sv, pagemap_builder.string_view())); TRY(region_object.finish()); } } diff --git a/Kernel/Random.cpp b/Kernel/Random.cpp index fedb562c19f..6d87ddfa8f8 100644 --- a/Kernel/Random.cpp +++ b/Kernel/Random.cpp @@ -73,7 +73,7 @@ void KernelRng::wait_for_entropy() SpinlockLocker lock(get_lock()); if (!is_ready()) { dbgln("Entropy starvation..."); - m_seed_queue.wait_forever("KernelRng"); + m_seed_queue.wait_forever("KernelRng"sv); } } diff --git a/Kernel/Scheduler.cpp b/Kernel/Scheduler.cpp index 8056c5a106e..d674b5829c1 100644 --- a/Kernel/Scheduler.cpp +++ b/Kernel/Scheduler.cpp @@ -401,11 +401,11 @@ UNMAP_AFTER_INIT void Scheduler::initialize() g_finalizer_wait_queue = new WaitQueue; g_finalizer_has_work.store(false, AK::MemoryOrder::memory_order_release); - s_colonel_process = Process::create_kernel_process(idle_thread, KString::must_create("colonel"), idle_loop, nullptr, 1, Process::RegisterProcess::No).leak_ref(); + s_colonel_process = Process::create_kernel_process(idle_thread, KString::must_create("colonel"sv), idle_loop, nullptr, 1, Process::RegisterProcess::No).leak_ref(); VERIFY(s_colonel_process); VERIFY(idle_thread); idle_thread->set_priority(THREAD_PRIORITY_MIN); - idle_thread->set_name(KString::must_create("Idle Task #0")); + idle_thread->set_name(KString::must_create("Idle Task #0"sv)); set_idle_thread(idle_thread); } diff --git a/Kernel/Storage/ATA/AHCIController.cpp b/Kernel/Storage/ATA/AHCIController.cpp index 7e353bcb9e2..f66ec99ed89 100644 --- a/Kernel/Storage/ATA/AHCIController.cpp +++ b/Kernel/Storage/ATA/AHCIController.cpp @@ -155,7 +155,7 @@ AHCI::HBADefinedCapabilities AHCIController::capabilities() const UNMAP_AFTER_INIT NonnullOwnPtr AHCIController::default_hba_region() const { - return MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR5(pci_address())).page_base(), Memory::page_round_up(sizeof(AHCI::HBA)).release_value_but_fixme_should_propagate_errors(), "AHCI HBA", Memory::Region::Access::ReadWrite).release_value(); + return MM.allocate_kernel_region(PhysicalAddress(PCI::get_BAR5(pci_address())).page_base(), Memory::page_round_up(sizeof(AHCI::HBA)).release_value_but_fixme_should_propagate_errors(), "AHCI HBA"sv, Memory::Region::Access::ReadWrite).release_value(); } AHCIController::~AHCIController() = default; diff --git a/Kernel/Storage/ATA/AHCIPort.cpp b/Kernel/Storage/ATA/AHCIPort.cpp index cb688fc9738..f303cd6e7ff 100644 --- a/Kernel/Storage/ATA/AHCIPort.cpp +++ b/Kernel/Storage/ATA/AHCIPort.cpp @@ -46,7 +46,7 @@ ErrorOr AHCIPort::allocate_resources_and_initialize_ports() m_command_table_pages.append(move(command_table_page)); } - m_command_list_region = TRY(MM.allocate_dma_buffer_page("AHCI Port Command List", Memory::Region::Access::ReadWrite, m_command_list_page)); + m_command_list_region = TRY(MM.allocate_dma_buffer_page("AHCI Port Command List"sv, Memory::Region::Access::ReadWrite, m_command_list_page)); dbgln_if(AHCI_DEBUG, "AHCI Port {}: Command list page at {}", representative_port_index(), m_command_list_page->paddr()); dbgln_if(AHCI_DEBUG, "AHCI Port {}: FIS receive page at {}", representative_port_index(), m_fis_receive_page->paddr()); @@ -220,7 +220,7 @@ void AHCIPort::eject() // handshake error bit in PxSERR register if CFL is incorrect. command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P | AHCI::CommandHeaderAttributes::C | AHCI::CommandHeaderAttributes::A; - auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value(); + auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value(); auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr(); memset(const_cast(command_table.command_fis), 0, 64); auto& fis = *(volatile FIS::HostToDevice::Register*)command_table.command_fis; @@ -590,7 +590,7 @@ bool AHCIPort::access_device(AsyncBlockDeviceRequest::RequestType direction, u64 dbgln_if(AHCI_DEBUG, "AHCI Port {}: CLE: ctba={:#08x}, ctbau={:#08x}, prdbc={:#08x}, prdtl={:#04x}, attributes={:#04x}", representative_port_index(), (u32)command_list_entries[unused_command_header.value()].ctba, (u32)command_list_entries[unused_command_header.value()].ctbau, (u32)command_list_entries[unused_command_header.value()].prdbc, (u16)command_list_entries[unused_command_header.value()].prdtl, (u16)command_list_entries[unused_command_header.value()].attributes); - auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table", Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value(); + auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite, Memory::Region::Cacheable::No).release_value(); auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr(); dbgln_if(AHCI_DEBUG, "AHCI Port {}: Allocated command table at {}", representative_port_index(), command_table_region->vaddr()); @@ -678,7 +678,7 @@ bool AHCIPort::identify_device() // QEMU doesn't care if we don't set the correct CFL field in this register, real hardware will set an handshake error bit in PxSERR register. command_list_entries[unused_command_header.value()].attributes = (size_t)FIS::DwordCount::RegisterHostToDevice | AHCI::CommandHeaderAttributes::P; - auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table", Memory::Region::Access::ReadWrite).release_value(); + auto command_table_region = MM.allocate_kernel_region(m_command_table_pages[unused_command_header.value()].paddr().page_base(), Memory::page_round_up(sizeof(AHCI::CommandTable)).value(), "AHCI Command Table"sv, Memory::Region::Access::ReadWrite).release_value(); auto& command_table = *(volatile AHCI::CommandTable*)command_table_region->vaddr().as_ptr(); memset(const_cast(command_table.command_fis), 0, 64); command_table.descriptors[0].base_high = 0; diff --git a/Kernel/Storage/ATA/AHCIPort.h b/Kernel/Storage/ATA/AHCIPort.h index 0bc5467a959..8f24ae734db 100644 --- a/Kernel/Storage/ATA/AHCIPort.h +++ b/Kernel/Storage/ATA/AHCIPort.h @@ -106,7 +106,7 @@ private: EntropySource m_entropy_source; RefPtr m_current_request; Spinlock m_hard_lock; - Mutex m_lock { "AHCIPort" }; + Mutex m_lock { "AHCIPort"sv }; mutable bool m_wait_for_completion { false }; diff --git a/Kernel/Storage/ATA/ATADiskDevice.cpp b/Kernel/Storage/ATA/ATADiskDevice.cpp index d0229b7c6ce..321719beb9f 100644 --- a/Kernel/Storage/ATA/ATADiskDevice.cpp +++ b/Kernel/Storage/ATA/ATADiskDevice.cpp @@ -35,7 +35,7 @@ ATADiskDevice::~ATADiskDevice() = default; StringView ATADiskDevice::class_name() const { - return "ATADiskDevice"; + return "ATADiskDevice"sv; } } diff --git a/Kernel/Storage/ATA/ATAPIDiscDevice.cpp b/Kernel/Storage/ATA/ATAPIDiscDevice.cpp index ac8ee20f945..f696043ecd3 100644 --- a/Kernel/Storage/ATA/ATAPIDiscDevice.cpp +++ b/Kernel/Storage/ATA/ATAPIDiscDevice.cpp @@ -35,7 +35,7 @@ ATAPIDiscDevice::~ATAPIDiscDevice() = default; StringView ATAPIDiscDevice::class_name() const { - return "ATAPIDiscDevice"; + return "ATAPIDiscDevice"sv; } } diff --git a/Kernel/Storage/ATA/BMIDEChannel.cpp b/Kernel/Storage/ATA/BMIDEChannel.cpp index e938669a1ad..cc29eaaf9f7 100644 --- a/Kernel/Storage/ATA/BMIDEChannel.cpp +++ b/Kernel/Storage/ATA/BMIDEChannel.cpp @@ -40,13 +40,13 @@ UNMAP_AFTER_INIT void BMIDEChannel::initialize() VERIFY(m_io_group.bus_master_base().has_value()); // Let's try to set up DMA transfers. { - auto region_or_error = MM.allocate_dma_buffer_page("IDE PRDT", Memory::Region::Access::ReadWrite, m_prdt_page); + auto region_or_error = MM.allocate_dma_buffer_page("IDE PRDT"sv, Memory::Region::Access::ReadWrite, m_prdt_page); if (region_or_error.is_error()) TODO(); m_prdt_region = region_or_error.release_value(); } { - auto region_or_error = MM.allocate_dma_buffer_page("IDE DMA region", Memory::Region::Access::ReadWrite, m_dma_buffer_page); + auto region_or_error = MM.allocate_dma_buffer_page("IDE DMA region"sv, Memory::Region::Access::ReadWrite, m_dma_buffer_page); if (region_or_error.is_error()) TODO(); m_dma_buffer_region = region_or_error.release_value(); diff --git a/Kernel/Storage/ATA/IDEChannel.h b/Kernel/Storage/ATA/IDEChannel.h index 4c9aa03d3ed..6d1bf1303a3 100644 --- a/Kernel/Storage/ATA/IDEChannel.h +++ b/Kernel/Storage/ATA/IDEChannel.h @@ -158,7 +158,7 @@ protected: u64 m_current_request_block_index { 0 }; bool m_current_request_flushing_cache { false }; Spinlock m_request_lock; - Mutex m_lock { "IDEChannel" }; + Mutex m_lock { "IDEChannel"sv }; IOAddressGroup m_io_group; NonnullRefPtr m_parent_controller; diff --git a/Kernel/Storage/NVMe/NVMeController.cpp b/Kernel/Storage/NVMe/NVMeController.cpp index d1c0fcf2d5b..5744dee0f1c 100644 --- a/Kernel/Storage/NVMe/NVMeController.cpp +++ b/Kernel/Storage/NVMe/NVMeController.cpp @@ -158,7 +158,7 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::identify_and_init_namespaces() u32 active_namespace_list[NVMe_IDENTIFY_SIZE / sizeof(u32)]; { - auto buffer = TRY(MM.allocate_dma_buffer_page("Identify PRP", Memory::Region::Access::ReadWrite, prp_dma_buffer)); + auto buffer = TRY(MM.allocate_dma_buffer_page("Identify PRP"sv, Memory::Region::Access::ReadWrite, prp_dma_buffer)); prp_dma_region = move(buffer); } @@ -269,7 +269,7 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::create_admin_queue(Optional i return EFAULT; } { - auto buffer = TRY(MM.allocate_dma_buffer_pages(cq_size, "Admin CQ queue", Memory::Region::Access::ReadWrite, cq_dma_pages)); + auto buffer = TRY(MM.allocate_dma_buffer_pages(cq_size, "Admin CQ queue"sv, Memory::Region::Access::ReadWrite, cq_dma_pages)); cq_dma_region = move(buffer); } @@ -278,7 +278,7 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::create_admin_queue(Optional i memset(cq_dma_region->vaddr().as_ptr(), 0, cq_size); { - auto buffer = TRY(MM.allocate_dma_buffer_pages(sq_size, "Admin SQ queue", Memory::Region::Access::ReadWrite, sq_dma_pages)); + auto buffer = TRY(MM.allocate_dma_buffer_pages(sq_size, "Admin SQ queue"sv, Memory::Region::Access::ReadWrite, sq_dma_pages)); sq_dma_region = move(buffer); } auto doorbell_regs = TRY(Memory::map_typed_writable(PhysicalAddress(m_bar + REG_SQ0TDBL_START))); @@ -307,7 +307,7 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::create_io_queue(u8 qid, Optional< auto sq_size = round_up_to_power_of_two(SQ_SIZE(IO_QUEUE_SIZE), 4096); { - auto buffer = TRY(MM.allocate_dma_buffer_pages(cq_size, "IO CQ queue", Memory::Region::Access::ReadWrite, cq_dma_pages)); + auto buffer = TRY(MM.allocate_dma_buffer_pages(cq_size, "IO CQ queue"sv, Memory::Region::Access::ReadWrite, cq_dma_pages)); cq_dma_region = move(buffer); } @@ -316,7 +316,7 @@ UNMAP_AFTER_INIT ErrorOr NVMeController::create_io_queue(u8 qid, Optional< memset(cq_dma_region->vaddr().as_ptr(), 0, cq_size); { - auto buffer = TRY(MM.allocate_dma_buffer_pages(sq_size, "IO SQ queue", Memory::Region::Access::ReadWrite, sq_dma_pages)); + auto buffer = TRY(MM.allocate_dma_buffer_pages(sq_size, "IO SQ queue"sv, Memory::Region::Access::ReadWrite, sq_dma_pages)); sq_dma_region = move(buffer); } diff --git a/Kernel/Storage/Ramdisk/Controller.cpp b/Kernel/Storage/Ramdisk/Controller.cpp index 81f5a079b9d..45de8cde44e 100644 --- a/Kernel/Storage/Ramdisk/Controller.cpp +++ b/Kernel/Storage/Ramdisk/Controller.cpp @@ -44,7 +44,7 @@ RamdiskController::RamdiskController() for (auto& used_memory_range : MM.used_memory_ranges()) { if (used_memory_range.type == Memory::UsedMemoryRangeType::BootModule) { size_t length = Memory::page_round_up(used_memory_range.end.get()).release_value_but_fixme_should_propagate_errors() - used_memory_range.start.get(); - auto region_or_error = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Memory::Region::Access::ReadWrite); + auto region_or_error = MM.allocate_kernel_region(used_memory_range.start, length, "Ramdisk"sv, Memory::Region::Access::ReadWrite); if (region_or_error.is_error()) { dmesgln("RamdiskController: Failed to allocate kernel region of size {}", length); } else { diff --git a/Kernel/Storage/Ramdisk/Device.h b/Kernel/Storage/Ramdisk/Device.h index 1747bd4eaed..0e4ef6cca9b 100644 --- a/Kernel/Storage/Ramdisk/Device.h +++ b/Kernel/Storage/Ramdisk/Device.h @@ -33,7 +33,7 @@ private: // ^StorageDevice virtual CommandSet command_set() const override { return CommandSet::PlainMemory; } - Mutex m_lock { "RamdiskDevice" }; + Mutex m_lock { "RamdiskDevice"sv }; NonnullOwnPtr m_region; }; diff --git a/Kernel/Syscalls/execve.cpp b/Kernel/Syscalls/execve.cpp index 0ec380a6ee2..428ba887a8b 100644 --- a/Kernel/Syscalls/execve.cpp +++ b/Kernel/Syscalls/execve.cpp @@ -173,7 +173,7 @@ static ErrorOr get_required_load_range(OpenFileDescription& p size_t executable_size = inode.size(); size_t rounded_executable_size = TRY(Memory::page_round_up(executable_size)); - auto region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, rounded_executable_size, "ELF memory range calculation", Memory::Region::Access::Read)); + auto region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, rounded_executable_size, "ELF memory range calculation"sv, Memory::Region::Access::Read)); auto elf_image = ELF::Image(region->vaddr().as_ptr(), executable_size); if (!elf_image.is_valid()) { return EINVAL; @@ -269,7 +269,7 @@ static ErrorOr load_elf_object(NonnullOwnPtr n size_t executable_size = inode.size(); size_t rounded_executable_size = TRY(Memory::page_round_up(executable_size)); - auto executable_region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, rounded_executable_size, "ELF loading", Memory::Region::Access::Read)); + auto executable_region = TRY(MM.allocate_kernel_region_with_vmobject(*vmobject, rounded_executable_size, "ELF loading"sv, Memory::Region::Access::Read)); auto elf_image = ELF::Image(executable_region->vaddr().as_ptr(), executable_size); if (!elf_image.is_valid()) @@ -392,7 +392,7 @@ static ErrorOr load_elf_object(NonnullOwnPtr n return ENOEXEC; } - auto* stack_region = TRY(new_space->allocate_region(Memory::RandomizeVirtualAddress::Yes, {}, Thread::default_userspace_stack_size, PAGE_SIZE, "Stack (Main thread)", PROT_READ | PROT_WRITE, AllocationStrategy::Reserve)); + auto* stack_region = TRY(new_space->allocate_region(Memory::RandomizeVirtualAddress::Yes, {}, Thread::default_userspace_stack_size, PAGE_SIZE, "Stack (Main thread)"sv, PROT_READ | PROT_WRITE, AllocationStrategy::Reserve)); stack_region->set_stack(true); return LoadResult { @@ -488,7 +488,7 @@ ErrorOr Process::do_exec(NonnullRefPtr main_program_d bool has_interpreter = interpreter_description; interpreter_description = nullptr; - auto* signal_trampoline_region = TRY(load_result.space->allocate_region_with_vmobject(Memory::RandomizeVirtualAddress::Yes, {}, PAGE_SIZE, PAGE_SIZE, g_signal_trampoline_region->vmobject(), 0, "Signal trampoline", PROT_READ | PROT_EXEC, true)); + auto* signal_trampoline_region = TRY(load_result.space->allocate_region_with_vmobject(Memory::RandomizeVirtualAddress::Yes, {}, PAGE_SIZE, PAGE_SIZE, g_signal_trampoline_region->vmobject(), 0, "Signal trampoline"sv, PROT_READ | PROT_EXEC, true)); signal_trampoline_region->set_syscall_region(true); // (For dynamically linked executable) Allocate an FD for passing the main executable to the dynamic loader. diff --git a/Kernel/Syscalls/pledge.cpp b/Kernel/Syscalls/pledge.cpp index 6759801c163..c6b7fc5ec06 100644 --- a/Kernel/Syscalls/pledge.cpp +++ b/Kernel/Syscalls/pledge.cpp @@ -31,7 +31,7 @@ ErrorOr Process::sys$pledge(Userspace auto found_invalid_pledge = true; pledge_spec.for_each_split_view(' ', false, [&mask, &found_invalid_pledge](auto const& part) { #define __ENUMERATE_PLEDGE_PROMISE(x) \ - if (part == StringView { #x }) { \ + if (part == #x##sv) { \ mask |= (1u << (u32)Pledge::x); \ return; \ } diff --git a/Kernel/TTY/TTY.cpp b/Kernel/TTY/TTY.cpp index c8f0b689991..5f4ea788a7e 100644 --- a/Kernel/TTY/TTY.cpp +++ b/Kernel/TTY/TTY.cpp @@ -398,18 +398,18 @@ ErrorOr TTY::set_termios(termios const& t) }; constexpr FlagDescription unimplemented_iflags[] = { - { IGNBRK, "IGNBRK" }, - { BRKINT, "BRKINT" }, - { IGNPAR, "IGNPAR" }, - { PARMRK, "PARMRK" }, - { INPCK, "INPCK" }, - { IGNCR, "IGNCR" }, - { IUCLC, "IUCLC" }, - { IXON, "IXON" }, - { IXANY, "IXANY" }, - { IXOFF, "IXOFF" }, - { IMAXBEL, "IMAXBEL" }, - { IUTF8, "IUTF8" } + { IGNBRK, "IGNBRK"sv }, + { BRKINT, "BRKINT"sv }, + { IGNPAR, "IGNPAR"sv }, + { PARMRK, "PARMRK"sv }, + { INPCK, "INPCK"sv }, + { IGNCR, "IGNCR"sv }, + { IUCLC, "IUCLC"sv }, + { IXON, "IXON"sv }, + { IXANY, "IXANY"sv }, + { IXOFF, "IXOFF"sv }, + { IMAXBEL, "IMAXBEL"sv }, + { IUTF8, "IUTF8"sv } }; for (auto flag : unimplemented_iflags) { if (m_termios.c_iflag & flag.value) { @@ -419,11 +419,11 @@ ErrorOr TTY::set_termios(termios const& t) } constexpr FlagDescription unimplemented_oflags[] = { - { OLCUC, "OLCUC" }, - { ONOCR, "ONOCR" }, - { ONLRET, "ONLRET" }, - { OFILL, "OFILL" }, - { OFDEL, "OFDEL" } + { OLCUC, "OLCUC"sv }, + { ONOCR, "ONOCR"sv }, + { ONLRET, "ONLRET"sv }, + { OFILL, "OFILL"sv }, + { OFDEL, "OFDEL"sv } }; for (auto flag : unimplemented_oflags) { if (m_termios.c_oflag & flag.value) { @@ -438,12 +438,12 @@ ErrorOr TTY::set_termios(termios const& t) } constexpr FlagDescription unimplemented_cflags[] = { - { CSTOPB, "CSTOPB" }, - { CREAD, "CREAD" }, - { PARENB, "PARENB" }, - { PARODD, "PARODD" }, - { HUPCL, "HUPCL" }, - { CLOCAL, "CLOCAL" } + { CSTOPB, "CSTOPB"sv }, + { CREAD, "CREAD"sv }, + { PARENB, "PARENB"sv }, + { PARODD, "PARODD"sv }, + { HUPCL, "HUPCL"sv }, + { CLOCAL, "CLOCAL"sv } }; for (auto flag : unimplemented_cflags) { if (m_termios.c_cflag & flag.value) { @@ -453,8 +453,8 @@ ErrorOr TTY::set_termios(termios const& t) } constexpr FlagDescription unimplemented_lflags[] = { - { TOSTOP, "TOSTOP" }, - { IEXTEN, "IEXTEN" } + { TOSTOP, "TOSTOP"sv }, + { IEXTEN, "IEXTEN"sv } }; for (auto flag : unimplemented_lflags) { if (m_termios.c_lflag & flag.value) { diff --git a/Kernel/TTY/VirtualConsole.cpp b/Kernel/TTY/VirtualConsole.cpp index fb39f196fd2..16986626fdf 100644 --- a/Kernel/TTY/VirtualConsole.cpp +++ b/Kernel/TTY/VirtualConsole.cpp @@ -135,7 +135,7 @@ UNMAP_AFTER_INIT void VirtualConsole::initialize() // Allocate twice of the max row * max column * sizeof(Cell) to ensure we can have some sort of history mechanism... auto size = GraphicsManagement::the().console()->max_column() * GraphicsManagement::the().console()->max_row() * sizeof(Cell) * 2; - m_cells = MM.allocate_kernel_region(Memory::page_round_up(size).release_value_but_fixme_should_propagate_errors(), "Virtual Console Cells", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value(); + m_cells = MM.allocate_kernel_region(Memory::page_round_up(size).release_value_but_fixme_should_propagate_errors(), "Virtual Console Cells"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value(); // Add the lines, so we also ensure they will be flushed now for (size_t row = 0; row < rows(); row++) { @@ -154,7 +154,7 @@ void VirtualConsole::refresh_after_resolution_change() // Note: From now on, columns() and rows() are updated with the new settings. auto size = GraphicsManagement::the().console()->max_column() * GraphicsManagement::the().console()->max_row() * sizeof(Cell) * 2; - auto new_cells = MM.allocate_kernel_region(Memory::page_round_up(size).release_value_but_fixme_should_propagate_errors(), "Virtual Console Cells", Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value(); + auto new_cells = MM.allocate_kernel_region(Memory::page_round_up(size).release_value_but_fixme_should_propagate_errors(), "Virtual Console Cells"sv, Memory::Region::Access::ReadWrite, AllocationStrategy::AllocateNow).release_value(); if (rows() < old_rows_count) { m_lines.shrink(rows()); diff --git a/Kernel/Tasks/SyncTask.cpp b/Kernel/Tasks/SyncTask.cpp index 19fa77c4a91..d895df2c0ba 100644 --- a/Kernel/Tasks/SyncTask.cpp +++ b/Kernel/Tasks/SyncTask.cpp @@ -15,7 +15,7 @@ namespace Kernel { UNMAP_AFTER_INIT void SyncTask::spawn() { RefPtr syncd_thread; - (void)Process::create_kernel_process(syncd_thread, KString::must_create("VFS Sync Task"), [] { + (void)Process::create_kernel_process(syncd_thread, KString::must_create("VFS Sync Task"sv), [] { dbgln("VFS SyncTask is running"); for (;;) { VirtualFileSystem::sync(); diff --git a/Kernel/Thread.cpp b/Kernel/Thread.cpp index 2d84d761af9..1ab509f01d9 100644 --- a/Kernel/Thread.cpp +++ b/Kernel/Thread.cpp @@ -1359,7 +1359,7 @@ static ErrorOr symbolicate(RecognizedSymbol const& symbol, Process& proces bool mask_kernel_addresses = !process.is_superuser(); if (!symbol.symbol) { if (!Memory::is_user_address(VirtualAddress(symbol.address))) { - TRY(builder.try_append("0xdeadc0de\n")); + TRY(builder.try_append("0xdeadc0de\n"sv)); } else { if (auto* region = process.address_space().find_region_containing({ VirtualAddress(symbol.address), sizeof(FlatPtr) })) { size_t offset = symbol.address - region->vaddr().get(); @@ -1421,7 +1421,7 @@ ErrorOr Thread::make_thread_specific_region(Badge) if (!process().m_master_tls_region) return {}; - auto* region = TRY(process().address_space().allocate_region(Memory::RandomizeVirtualAddress::Yes, {}, thread_specific_region_size(), PAGE_SIZE, "Thread-specific", PROT_READ | PROT_WRITE)); + auto* region = TRY(process().address_space().allocate_region(Memory::RandomizeVirtualAddress::Yes, {}, thread_specific_region_size(), PAGE_SIZE, "Thread-specific"sv, PROT_READ | PROT_WRITE)); m_thread_specific_range = region->range(); @@ -1511,5 +1511,5 @@ ErrorOr AK::Formatter::format(FormatBuilder& builder, Kern { return AK::Formatter::format( builder, - "{}({}:{})", value.process().name(), value.pid().value(), value.tid().value()); + "{}({}:{})"sv, value.process().name(), value.pid().value(), value.tid().value()); } diff --git a/Kernel/Time/HPET.cpp b/Kernel/Time/HPET.cpp index 8493e40bb16..18c33811faa 100644 --- a/Kernel/Time/HPET.cpp +++ b/Kernel/Time/HPET.cpp @@ -127,7 +127,7 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize() { VERIFY(!HPET::initialized()); hpet_initialized = true; - auto hpet_table = ACPI::Parser::the()->find_table("HPET"); + auto hpet_table = ACPI::Parser::the()->find_table("HPET"sv); if (!hpet_table.has_value()) return false; dmesgln("HPET @ {}", hpet_table.value()); @@ -153,7 +153,7 @@ UNMAP_AFTER_INIT bool HPET::test_and_initialize() UNMAP_AFTER_INIT bool HPET::check_for_exisiting_periodic_timers() { - auto hpet_table = ACPI::Parser::the()->find_table("HPET"); + auto hpet_table = ACPI::Parser::the()->find_table("HPET"sv); if (!hpet_table.has_value()) return false; @@ -431,7 +431,7 @@ u64 HPET::ns_to_raw_counter_ticks(u64 ns) const UNMAP_AFTER_INIT HPET::HPET(PhysicalAddress acpi_hpet) : m_physical_acpi_hpet_table(acpi_hpet) , m_physical_acpi_hpet_registers(find_acpi_hpet_registers_block()) - , m_hpet_mmio_region(MM.allocate_kernel_region(m_physical_acpi_hpet_registers.page_base(), PAGE_SIZE, "HPET MMIO", Memory::Region::Access::ReadWrite).release_value()) + , m_hpet_mmio_region(MM.allocate_kernel_region(m_physical_acpi_hpet_registers.page_base(), PAGE_SIZE, "HPET MMIO"sv, Memory::Region::Access::ReadWrite).release_value()) { s_hpet = this; // Make available as soon as possible so that IRQs can use it diff --git a/Kernel/UBSanitizer.cpp b/Kernel/UBSanitizer.cpp index 3cc6292723c..5d714bcaea0 100644 --- a/Kernel/UBSanitizer.cpp +++ b/Kernel/UBSanitizer.cpp @@ -127,18 +127,18 @@ void __ubsan_handle_type_mismatch_v1(TypeMismatchData const&, ValueHandle) __att void __ubsan_handle_type_mismatch_v1(TypeMismatchData const& data, ValueHandle ptr) { constexpr StringView kinds[] = { - "load of", - "store to", - "reference binding to", - "member access within", - "member call on", - "constructor call on", - "downcast of", - "downcast of", - "upcast of", - "cast to virtual base of", - "_Nonnull binding to", - "dynamic operation on" + "load of"sv, + "store to"sv, + "reference binding to"sv, + "member access within"sv, + "member call on"sv, + "constructor call on"sv, + "downcast of"sv, + "downcast of"sv, + "upcast of"sv, + "cast to virtual base of"sv, + "_Nonnull binding to"sv, + "dynamic operation on"sv }; FlatPtr alignment = (FlatPtr)1 << data.log_alignment; diff --git a/Kernel/VirtualAddress.h b/Kernel/VirtualAddress.h index 82ba5a88ef1..52817266cd4 100644 --- a/Kernel/VirtualAddress.h +++ b/Kernel/VirtualAddress.h @@ -56,6 +56,6 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, VirtualAddress const& value) { - return AK::Formatter::format(builder, "V{}", value.as_ptr()); + return AK::Formatter::format(builder, "V{}"sv, value.as_ptr()); } }; diff --git a/Kernel/WorkQueue.cpp b/Kernel/WorkQueue.cpp index 77978ff5ba7..a96882e6310 100644 --- a/Kernel/WorkQueue.cpp +++ b/Kernel/WorkQueue.cpp @@ -16,7 +16,7 @@ WorkQueue* g_io_work; UNMAP_AFTER_INIT void WorkQueue::initialize() { - g_io_work = new WorkQueue("IO WorkQueue Task"); + g_io_work = new WorkQueue("IO WorkQueue Task"sv); } UNMAP_AFTER_INIT WorkQueue::WorkQueue(StringView name) diff --git a/Kernel/init.cpp b/Kernel/init.cpp index bad8511cf05..e47255e8374 100644 --- a/Kernel/init.cpp +++ b/Kernel/init.cpp @@ -252,7 +252,7 @@ extern "C" [[noreturn]] UNMAP_AFTER_INIT void init(BootInfo const& boot_info) { RefPtr init_stage2_thread; - (void)Process::create_kernel_process(init_stage2_thread, KString::must_create("init_stage2"), init_stage2, nullptr, THREAD_AFFINITY_DEFAULT, Process::RegisterProcess::No); + (void)Process::create_kernel_process(init_stage2_thread, KString::must_create("init_stage2"sv), init_stage2, nullptr, THREAD_AFFINITY_DEFAULT, Process::RegisterProcess::No); // We need to make sure we drop the reference for init_stage2_thread // before calling into Scheduler::start, otherwise we will have a // dangling Thread that never gets cleaned up diff --git a/Meta/Lagom/TestJson.cpp b/Meta/Lagom/TestJson.cpp index f45f15cc399..132daeea034 100644 --- a/Meta/Lagom/TestJson.cpp +++ b/Meta/Lagom/TestJson.cpp @@ -10,8 +10,8 @@ int main(int, char**) { - auto value = JsonValue::from_string("{\"property\": \"value\"}").release_value_but_fixme_should_propagate_errors(); + auto value = JsonValue::from_string("{\"property\": \"value\"}"sv).release_value_but_fixme_should_propagate_errors(); printf("parsed: _%s_\n", value.to_string().characters()); - printf("object.property = '%s'\n", value.as_object().get("property").to_string().characters()); + printf("object.property = '%s'\n", value.as_object().get("property"sv).to_string().characters()); return 0; } diff --git a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp index 36680fbf86e..80c84fb95d8 100644 --- a/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/IPCCompiler/main.cpp @@ -49,7 +49,7 @@ struct Message { { StringBuilder builder; builder.append(pascal_case(name)); - builder.append("Response"); + builder.append("Response"sv); return builder.to_string(); } }; @@ -69,12 +69,12 @@ static bool is_primitive_type(String const& type) static String message_name(String const& endpoint, String const& message, bool is_response) { StringBuilder builder; - builder.append("Messages::"); + builder.append("Messages::"sv); builder.append(endpoint); - builder.append("::"); + builder.append("::"sv); builder.append(pascal_case(message)); if (is_response) - builder.append("Response"); + builder.append("Response"sv); return builder.to_string(); } @@ -261,7 +261,7 @@ String constructor_for_message(String const& name, Vector const& para builder.append(name); if (parameters.is_empty()) { - builder.append("() {}"); + builder.append("() {}"sv); return builder.to_string(); } builder.append('('); @@ -269,16 +269,16 @@ String constructor_for_message(String const& name, Vector const& para auto const& parameter = parameters[i]; builder.appendff("{} {}", parameter.type, parameter.name); if (i != parameters.size() - 1) - builder.append(", "); + builder.append(", "sv); } - builder.append(") : "); + builder.append(") : "sv); for (size_t i = 0; i < parameters.size(); ++i) { auto const& parameter = parameters[i]; builder.appendff("m_{}(move({}))", parameter.name, parameter.name); if (i != parameters.size() - 1) - builder.append(", "); + builder.append(", "sv); } - builder.append(" {}"); + builder.append(" {}"sv); return builder.to_string(); } @@ -343,7 +343,7 @@ public:)~~~"); auto const& parameter = parameters[i]; builder.appendff("move({})", parameter.name); if (i != parameters.size() - 1) - builder.append(", "); + builder.append(", "sv); } message_generator.set("message.constructor_call_parameters", builder.build()); @@ -657,11 +657,11 @@ public: StringBuilder argument_generator; for (size_t i = 0; i < parameters.size(); ++i) { auto const& parameter = parameters[i]; - argument_generator.append("request."); + argument_generator.append("request."sv); argument_generator.append(parameter.name); - argument_generator.append("()"); + argument_generator.append("()"sv); if (i != parameters.size() - 1) - argument_generator.append(", "); + argument_generator.append(", "sv); } message_generator.set("message.pascal_name", pascal_case(name)); @@ -722,7 +722,7 @@ public: builder.append(type); if (const_ref) - builder.append(" const&"); + builder.append(" const&"sv); return builder.to_string(); }; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp index bf5499d8fac..07e0ac578bb 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibTimeZone/GenerateTimeZoneData.cpp @@ -79,7 +79,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, DateTime const& date_time) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv, date_time.year, date_time.month.value_or(1), date_time.day.value_or(1), @@ -97,7 +97,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TimeZoneOffset const& time_zone_offset) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {} }}"sv, time_zone_offset.offset, time_zone_offset.until.value_or({}), time_zone_offset.until.has_value(), @@ -113,7 +113,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, DaylightSavingsOffset const& dst_offset) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {} }}"sv, dst_offset.offset, dst_offset.year_from, dst_offset.year_to, @@ -127,7 +127,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TimeZone::Coordinate const& coordinate) { return Formatter::format(builder, - "{{ {}, {}, {} }}", + "{{ {}, {}, {} }}"sv, coordinate.degrees, coordinate.minutes, coordinate.seconds); @@ -139,7 +139,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TimeZone::Location const& location) { return Formatter::format(builder, - "{{ {}, {} }}", + "{{ {}, {} }}"sv, location.latitude, location.longitude); } @@ -557,19 +557,19 @@ static constexpr Array<@type@, @size@> @name@ { { generator.append("} };\n"); }; - generate_mapping(generator, time_zone_data.time_zone_names, "TimeZoneOffset"sv, "s_time_zone_offsets"sv, "s_time_zone_offsets_{}", format_identifier, + generate_mapping(generator, time_zone_data.time_zone_names, "TimeZoneOffset"sv, "s_time_zone_offsets"sv, "s_time_zone_offsets_{}"sv, format_identifier, [&](auto const& name, auto const& value) { auto const& time_zone_offsets = time_zone_data.time_zones.find(value)->value; append_offsets(name, "TimeZoneOffset"sv, time_zone_offsets); }); - generate_mapping(generator, time_zone_data.dst_offset_names, "DaylightSavingsOffset"sv, "s_dst_offsets"sv, "s_dst_offsets_{}", format_identifier, + generate_mapping(generator, time_zone_data.dst_offset_names, "DaylightSavingsOffset"sv, "s_dst_offsets"sv, "s_dst_offsets_{}"sv, format_identifier, [&](auto const& name, auto const& value) { auto const& dst_offsets = time_zone_data.dst_offsets.find(value)->value; append_offsets(name, "DaylightSavingsOffset"sv, dst_offsets); }); - generate_mapping(generator, time_zone_data.time_zone_region_names, s_string_index_type, "s_regional_time_zones"sv, "s_regional_time_zones_{}", format_identifier, + generate_mapping(generator, time_zone_data.time_zone_region_names, s_string_index_type, "s_regional_time_zones"sv, "s_regional_time_zones_{}"sv, format_identifier, [&](auto const& name, auto const& value) { auto const& time_zones = time_zone_data.time_zone_regions.find(value)->value; @@ -581,7 +581,7 @@ static constexpr Array<@string_index_type@, @size@> @name@ { {)~~~"); bool first = true; for (auto const& time_zone : time_zones) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(time_zone)); first = false; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp index cee055b0802..29067bb499f 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeData.cpp @@ -146,8 +146,8 @@ struct UnicodeData { static String sanitize_entry(String const& entry) { - auto sanitized = entry.replace("-", "_", ReplaceMode::All); - sanitized = sanitized.replace(" ", "_", ReplaceMode::All); + auto sanitized = entry.replace("-"sv, "_"sv, ReplaceMode::All); + sanitized = sanitized.replace(" "sv, "_"sv, ReplaceMode::All); StringBuilder builder; bool next_is_upper = true; @@ -229,7 +229,7 @@ static ErrorOr parse_special_casing(Core::Stream::BufferedFile& file, Unic if (!casing.locale.is_empty()) casing.locale = String::formatted("{:c}{}", to_ascii_uppercase(casing.locale[0]), casing.locale.substring_view(1)); - casing.condition = casing.condition.replace("_", "", ReplaceMode::All); + casing.condition = casing.condition.replace("_"sv, ""sv, ReplaceMode::All); if (!casing.condition.is_empty() && !unicode_data.conditions.contains_slow(casing.condition)) unicode_data.conditions.append(casing.condition); @@ -570,7 +570,7 @@ static ErrorOr parse_unicode_data(Core::Stream::BufferedFile& file, Unicod if (!assigned_code_point_range_start.has_value()) assigned_code_point_range_start = data.code_point; - if (data.name.starts_with("<"sv) && data.name.ends_with(", First>")) { + if (data.name.starts_with("<"sv) && data.name.ends_with(", First>"sv)) { VERIFY(!code_point_range_start.has_value() && assigned_code_point_range_start.has_value()); code_point_range_start = data.code_point; @@ -578,7 +578,7 @@ static ErrorOr parse_unicode_data(Core::Stream::BufferedFile& file, Unicod assigned_code_points.append({ *assigned_code_point_range_start, previous_code_point }); assigned_code_point_range_start.clear(); - } else if (data.name.starts_with("<"sv) && data.name.ends_with(", Last>")) { + } else if (data.name.starts_with("<"sv) && data.name.ends_with(", Last>"sv)) { VERIFY(code_point_range_start.has_value()); CodePointRange code_point_range { *code_point_range_start, data.code_point }; @@ -739,7 +739,7 @@ namespace Unicode { bool first = true; generator.append(", {"); for (auto const& item : list) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::formatted(format, item)); first = false; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp index c2e478706c6..fc412bd15b0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeDateTimeFormat.cpp @@ -147,7 +147,7 @@ struct AK::Formatter : Formatter { }; return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv, pattern.skeleton_index, pattern.pattern_index, pattern.pattern12_index, @@ -212,7 +212,7 @@ struct AK::Formatter : Formatter { }; return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv, pattern.skeleton_index, field_to_i8(pattern.field), pattern.start_range, @@ -265,7 +265,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, CalendarFormat const& pattern) { return Formatter::format(builder, - "{{ {}, {}, {}, {} }}", + "{{ {}, {}, {}, {} }}"sv, pattern.full_format, pattern.long_format, pattern.medium_format, @@ -305,7 +305,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, CalendarSymbols const& symbols) { return Formatter::format(builder, - "{{ {}, {}, {} }}", + "{{ {}, {}, {} }}"sv, symbols.narrow_symbols, symbols.short_symbols, symbols.long_symbols); @@ -364,7 +364,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Calendar const& calendar) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {}, {} }}"sv, calendar.date_formats, calendar.time_formats, calendar.date_time_formats, @@ -418,7 +418,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TimeZoneNames const& time_zone) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {} }}"sv, time_zone.short_standard_name, time_zone.long_standard_name, time_zone.short_daylight_name, @@ -469,7 +469,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TimeZoneFormat const& time_zone_format) { - return Formatter::format(builder, "{{ {}, {}, {}, {}, {}, {} }}", + return Formatter::format(builder, "{{ {}, {}, {}, {}, {}, {} }}"sv, time_zone_format.symbol_ahead_sign, time_zone_format.symbol_ahead_separator, time_zone_format.symbol_behind_sign, @@ -510,7 +510,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, DayPeriod const& day_period) { return Formatter::format(builder, - "{{ {}, {}, {} }}", + "{{ {}, {}, {} }}"sv, static_cast(day_period.day_period), day_period.begin, day_period.end); @@ -825,7 +825,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Era if (all_of(segment, is_char('G'))) { - builder.append("{era}"); + builder.append("{era}"sv); if (segment.length() <= 3) format.era = CalendarPatternStyle::Short; @@ -837,7 +837,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Year else if (all_of(segment, is_any_of("yYuUr"sv))) { - builder.append("{year}"); + builder.append("{year}"sv); if (segment.length() == 2) format.year = CalendarPatternStyle::TwoDigit; @@ -853,7 +853,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Month else if (all_of(segment, is_any_of("ML"sv))) { - builder.append("{month}"); + builder.append("{month}"sv); if (segment.length() == 1) format.month = CalendarPatternStyle::Numeric; @@ -878,20 +878,20 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Day else if (all_of(segment, is_char('d'))) { - builder.append("{day}"); + builder.append("{day}"sv); if (segment.length() == 1) format.day = CalendarPatternStyle::Numeric; else format.day = CalendarPatternStyle::TwoDigit; } else if (all_of(segment, is_any_of("DFg"sv))) { - builder.append("{day}"); + builder.append("{day}"sv); format.day = CalendarPatternStyle::Numeric; } // Weekday else if (all_of(segment, is_char('E'))) { - builder.append("{weekday}"); + builder.append("{weekday}"sv); if (segment.length() == 4) format.weekday = CalendarPatternStyle::Long; @@ -900,7 +900,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str else format.weekday = CalendarPatternStyle::Short; } else if (all_of(segment, is_any_of("ec"sv))) { - builder.append("{weekday}"); + builder.append("{weekday}"sv); // TR-35 defines "e", "c", and "cc" as as numeric, and "ee" as 2-digit, but those // pattern styles are not supported by Intl.DateTimeFormat. @@ -917,10 +917,10 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Period else if (all_of(segment, is_any_of("ab"sv))) { - builder.append("{ampm}"); + builder.append("{ampm}"sv); hour12 = true; } else if (all_of(segment, is_char('B'))) { - builder.append("{dayPeriod}"); + builder.append("{dayPeriod}"sv); hour12 = true; if (segment.length() == 4) @@ -933,7 +933,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Hour else if (all_of(segment, is_any_of("hHKk"sv))) { - builder.append("{hour}"); + builder.append("{hour}"sv); if ((segment[0] == 'h') || (segment[0] == 'K')) hour12 = true; @@ -949,7 +949,7 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Minute else if (all_of(segment, is_char('m'))) { - builder.append("{minute}"); + builder.append("{minute}"sv); if (segment.length() == 1) format.minute = CalendarPatternStyle::Numeric; @@ -959,14 +959,14 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Second else if (all_of(segment, is_char('s'))) { - builder.append("{second}"); + builder.append("{second}"sv); if (segment.length() == 1) format.second = CalendarPatternStyle::Numeric; else format.second = CalendarPatternStyle::TwoDigit; } else if (all_of(segment, is_char('S'))) { - builder.append("{fractionalSecondDigits}"); + builder.append("{fractionalSecondDigits}"sv); VERIFY(segment.length() <= 3); format.fractional_second_digits = static_cast(segment.length()); @@ -977,21 +977,21 @@ static Optional parse_date_time_pattern_raw(String pattern, Str // Zone else if (all_of(segment, is_any_of("zV"sv))) { - builder.append("{timeZoneName}"); + builder.append("{timeZoneName}"sv); if (segment.length() < 4) format.time_zone_name = CalendarPatternStyle::Short; else format.time_zone_name = CalendarPatternStyle::Long; } else if (all_of(segment, is_any_of("ZOXx"sv))) { - builder.append("{timeZoneName}"); + builder.append("{timeZoneName}"sv); if (segment.length() < 4) format.time_zone_name = CalendarPatternStyle::ShortOffset; else format.time_zone_name = CalendarPatternStyle::LongOffset; } else if (all_of(segment, is_char('v'))) { - builder.append("{timeZoneName}"); + builder.append("{timeZoneName}"sv); if (segment.length() < 4) format.time_zone_name = CalendarPatternStyle::ShortGeneric; @@ -1166,7 +1166,7 @@ static void generate_missing_patterns(Calendar& calendar, CalendarPatternList& f auto time_pattern = locale_data.unique_strings.get(time_format); auto date_pattern = locale_data.unique_strings.get(date_format); - auto new_pattern = pattern.replace("{0}", time_pattern, ReplaceMode::FirstOnly).replace("{1}", date_pattern, ReplaceMode::FirstOnly); + auto new_pattern = pattern.replace("{0}"sv, time_pattern, ReplaceMode::FirstOnly).replace("{1}"sv, date_pattern, ReplaceMode::FirstOnly); return locale_data.unique_strings.ensure(move(new_pattern)); }; @@ -1958,7 +1958,7 @@ static constexpr Array<@calendar_index_type@, @size@> @name@ { {)~~~"); for (auto const& calendar_key : locale_data.calendars) { auto calendar = calendars.find(calendar_key)->value; - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(calendar)); first = false; } @@ -1979,7 +1979,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); auto const& value = map.find(key)->value; auto mapping = mapping_getter(value); - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(mapping)); first = false; } @@ -1990,7 +1990,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); auto locales = locale_data.locales.keys(); quick_sort(locales); - generate_mapping(generator, locale_data.locales, s_calendar_index_type, "s_locale_calendars"sv, "s_calendars_{}", format_identifier, [&](auto const& name, auto const& value) { append_calendars(name, value.calendars); }); + generate_mapping(generator, locale_data.locales, s_calendar_index_type, "s_locale_calendars"sv, "s_calendars_{}"sv, format_identifier, [&](auto const& name, auto const& value) { append_calendars(name, value.calendars); }); append_mapping(locales, locale_data.locales, s_time_zone_index_type, "s_locale_time_zones"sv, [](auto const& locale) { return locale.time_zones; }); append_mapping(locales, locale_data.locales, s_time_zone_format_index_type, "s_locale_time_zone_formats"sv, [](auto const& locale) { return locale.time_zone_formats; }); append_mapping(locales, locale_data.locales, s_day_period_index_type, "s_locale_day_periods"sv, [](auto const& locale) { return locale.day_periods; }); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp index f1247f303cc..1ec225e2866 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeLocale.cpp @@ -90,7 +90,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, DisplayPattern const& patterns) { return Formatter::format(builder, - "{{ {}, {} }}", + "{{ {}, {} }}"sv, patterns.locale_pattern, patterns.locale_separator); } @@ -135,7 +135,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, ListPatterns const& patterns) { return Formatter::format(builder, - "{{ ListPatternType::{}, Style::{}, {}, {}, {}, {} }}", + "{{ ListPatternType::{}, Style::{}, {}, {}, {}, {} }}"sv, format_identifier({}, patterns.type), format_identifier({}, patterns.style), patterns.start, @@ -169,7 +169,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, TextLayout const& patterns) { return Formatter::format(builder, - "{{ CharacterOrder::{} }}", + "{{ CharacterOrder::{} }}"sv, format_identifier({}, patterns.character_order)); } }; @@ -425,7 +425,7 @@ static ErrorOr parse_unicode_extension_keywords(String bcp47_path, Unicode if (!desired_keywords.span().contains_slow(key)) return; - auto const& name = value.as_object().get("_alias"); + auto const& name = value.as_object().get("_alias"sv); locale_data.keyword_names.set(key, name.as_string()); auto& keywords = locale_data.keywords.ensure(key); @@ -1156,7 +1156,7 @@ struct TextLayout { bool first = true; generator.append(", {"); for (auto const& item : list) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(item)); first = false; } @@ -1176,7 +1176,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); auto const& value = map.find(key)->value; auto mapping = mapping_getter(value); - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(mapping)); first = false; } diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp index 378b9bbb192..6e9a81e9eda 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeNumberFormat.cpp @@ -97,7 +97,7 @@ struct AK::Formatter : Formatter { identifier_indices.join(", "sv, format.identifier_indices); return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {{ {} }} }}", + "{{ {}, {}, {}, {}, {}, {}, {{ {} }} }}"sv, format.magnitude, format.exponent, to_underlying(format.plurality), @@ -173,7 +173,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, NumberSystem const& system) { return Formatter::format(builder, - "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}", + "{{ {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {} }}"sv, system.symbols, system.primary_grouping_size, system.secondary_grouping_size, @@ -223,7 +223,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Unit const& system) { return Formatter::format(builder, - "{{ {}, {}, {}, {} }}", + "{{ {}, {}, {}, {} }}"sv, system.unit, system.long_formats, system.short_formats, @@ -868,7 +868,7 @@ static constexpr Array s_minimum_grouping_digits { { )~~~"); bool first = true; for (auto const& locale : locales) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(locale_data.locales.find(locale)->value.minimum_grouping_digits)); first = false; } @@ -884,7 +884,7 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); bool first = true; for (auto const& item : map) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); if constexpr (requires { item.value; }) generator.append(String::number(item.value)); else @@ -895,9 +895,9 @@ static constexpr Array<@type@, @size@> @name@ { {)~~~"); generator.append(" } };"); }; - generate_mapping(generator, locale_data.number_system_digits, "u32"sv, "s_number_systems_digits"sv, "s_number_systems_digits_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, "u32"sv, value); }); - generate_mapping(generator, locale_data.locales, s_number_system_index_type, "s_locale_number_systems"sv, "s_number_systems_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, s_number_system_index_type, value.number_systems); }); - generate_mapping(generator, locale_data.locales, s_unit_index_type, "s_locale_units"sv, "s_units_{}", nullptr, [&](auto const& name, auto const& value) { append_map(name, s_unit_index_type, value.units); }); + generate_mapping(generator, locale_data.number_system_digits, "u32"sv, "s_number_systems_digits"sv, "s_number_systems_digits_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, "u32"sv, value); }); + generate_mapping(generator, locale_data.locales, s_number_system_index_type, "s_locale_number_systems"sv, "s_number_systems_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, s_number_system_index_type, value.number_systems); }); + generate_mapping(generator, locale_data.locales, s_unit_index_type, "s_locale_units"sv, "s_units_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_map(name, s_unit_index_type, value.units); }); generator.append(R"~~~( static Optional keyword_to_number_system(KeywordNumbers keyword) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodePluralRules.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodePluralRules.cpp index 559e36746f7..f5e87b54695 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodePluralRules.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodePluralRules.cpp @@ -591,13 +591,13 @@ static constexpr Array @name@ { { PluralCategory::Other) append_lookup_table("PluralCategoryFunction"sv, "ordinal"sv, "default_category"sv, [](auto& rules, auto form) -> Conditions& { return rules.rules_for_form(form); }); append_lookup_table("PluralRangeFunction"sv, "range"sv, "default_range"sv, [](auto& rules, auto) -> Ranges& { return rules.plural_ranges; }); - generate_mapping(generator, locales, "PluralCategory"sv, "s_cardinal_categories"sv, "s_cardinal_categories_{}", format_identifier, + generate_mapping(generator, locales, "PluralCategory"sv, "s_cardinal_categories"sv, "s_cardinal_categories_{}"sv, format_identifier, [&](auto const& name, auto const& locale) { auto& rules = locale_data.locales.find(locale)->value; append_categories(name, rules.rules_for_form("cardinal"sv)); }); - generate_mapping(generator, locales, "PluralCategory"sv, "s_ordinal_categories"sv, "s_ordinal_categories_{}", format_identifier, + generate_mapping(generator, locales, "PluralCategory"sv, "s_ordinal_categories"sv, "s_ordinal_categories_{}"sv, format_identifier, [&](auto const& name, auto const& locale) { auto& rules = locale_data.locales.find(locale)->value; append_categories(name, rules.rules_for_form("ordinal"sv)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeRelativeTimeFormat.cpp b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeRelativeTimeFormat.cpp index 02ee5b4d54e..12bd97c26e4 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeRelativeTimeFormat.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GenerateUnicodeRelativeTimeFormat.cpp @@ -58,7 +58,7 @@ struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, RelativeTimeFormat const& format) { return Formatter::format(builder, - "{{ TimeUnit::{}, Style::{}, PluralCategory::{}, {}, {} }}", + "{{ TimeUnit::{}, Style::{}, PluralCategory::{}, {}, {} }}"sv, format.time_unit, format.style, format.plurality, @@ -242,7 +242,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~ bool first = true; for (auto index : list) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::number(index)); first = false; } @@ -250,7 +250,7 @@ static constexpr Array<@relative_time_format_index_type@, @size@> @name@ { {)~~~ generator.append(" } };"); }; - generate_mapping(generator, locale_data.locales, s_relative_time_format_index_type, "s_locale_relative_time_formats"sv, "s_number_systems_digits_{}", nullptr, [&](auto const& name, auto const& value) { append_list(name, value.time_units); }); + generate_mapping(generator, locale_data.locales, s_relative_time_format_index_type, "s_locale_relative_time_formats"sv, "s_number_systems_digits_{}"sv, nullptr, [&](auto const& name, auto const& value) { append_list(name, value.time_units); }); generator.append(R"~~~( Vector get_relative_time_format_patterns(StringView locale, TimeUnit time_unit, StringView tense_or_number, Style style) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h index 650e1656bc5..0cd143737f0 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibUnicode/GeneratorUtil.h @@ -136,7 +136,7 @@ static constexpr Array<@type@, @size@> @name@@index@ { {)~~~"); bool first = true; for (auto const& value : list) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); generator.append(String::formatted("{}", value)); first = false; } @@ -538,7 +538,7 @@ Span @name@() bool first = true; for (auto const& value : values) { - generator.append(first ? " " : ", "); + generator.append(first ? " "sv : ", "sv); first = false; if (auto it = aliases.find_if([&](auto const& alias) { return alias.alias == value; }); it != aliases.end()) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp index 63fdbdc5d0c..9d8378d95b6 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSMediaFeatureID.cpp @@ -137,8 +137,8 @@ bool media_feature_type_is_range(MediaFeatureID media_feature_id) auto member_generator = generator.fork(); member_generator.set("name:titlecase", title_casify(name)); - VERIFY(feature.has("type")); - auto feature_type = feature.get("type"); + VERIFY(feature.has("type"sv)); + auto feature_type = feature.get("type"sv); VERIFY(feature_type.is_string()); member_generator.set("is_range", feature_type.as_string() == "range" ? "true" : "false"); member_generator.append(R"~~~( @@ -165,7 +165,7 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal case MediaFeatureID::@name:titlecase@:)~~~"); bool have_output_value_type_switch = false; - if (feature.has("values")) { + if (feature.has("values"sv)) { auto append_value_type_switch_if_needed = [&]() { if (!have_output_value_type_switch) { member_generator.append(R"~~~( @@ -173,7 +173,7 @@ bool media_feature_accepts_type(MediaFeatureID media_feature_id, MediaFeatureVal } have_output_value_type_switch = true; }; - auto& values = feature.get("values"); + auto& values = feature.get("values"sv); VERIFY(values.is_array()); auto& values_array = values.as_array(); for (auto& type : values_array.values()) { @@ -243,7 +243,7 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i case MediaFeatureID::@name:titlecase@:)~~~"); bool have_output_identifier_switch = false; - if (feature.has("values")) { + if (feature.has("values"sv)) { auto append_identifier_switch_if_needed = [&]() { if (!have_output_identifier_switch) { member_generator.append(R"~~~( @@ -251,7 +251,7 @@ bool media_feature_accepts_identifier(MediaFeatureID media_feature_id, ValueID i } have_output_identifier_switch = true; }; - auto& values = feature.get("values"); + auto& values = feature.get("values"sv); VERIFY(values.is_array()); auto& values_array = values.as_array(); for (auto& identifier : values_array.values()) { diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp index 16ec1e2c34f..2302e04581a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPropertyID.cpp @@ -63,7 +63,7 @@ enum class PropertyID { properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (value.as_object().has("longhands")) + if (value.as_object().has("longhands"sv)) shorthand_property_ids.append(name); else longhand_property_ids.append(name); @@ -104,7 +104,7 @@ enum class PropertyID { PropertyID property_id_from_camel_case_string(StringView); PropertyID property_id_from_string(StringView); -const char* string_from_property_id(PropertyID); +StringView string_from_property_id(PropertyID); bool is_inherited_property(PropertyID); NonnullRefPtr property_initial_value(PropertyID); @@ -189,7 +189,7 @@ PropertyID property_id_from_string(StringView string) member_generator.set("name", name); member_generator.set("name:titlecase", title_casify(name)); member_generator.append(R"~~~( - if (string.equals_ignoring_case("@name@")) + if (string.equals_ignoring_case("@name@"sv)) return PropertyID::@name:titlecase@; )~~~"); }); @@ -198,7 +198,7 @@ PropertyID property_id_from_string(StringView string) return PropertyID::Invalid; } -const char* string_from_property_id(PropertyID property_id) { +StringView string_from_property_id(PropertyID property_id) { switch (property_id) { )~~~"); @@ -210,13 +210,13 @@ const char* string_from_property_id(PropertyID property_id) { member_generator.set("name:titlecase", title_casify(name)); member_generator.append(R"~~~( case PropertyID::@name:titlecase@: - return "@name@"; + return "@name@"sv; )~~~"); }); generator.append(R"~~~( default: - return "(invalid CSS::PropertyID)"; + return "(invalid CSS::PropertyID)"sv; } } @@ -229,8 +229,8 @@ bool is_inherited_property(PropertyID property_id) VERIFY(value.is_object()); bool inherited = false; - if (value.as_object().has("inherited")) { - auto& inherited_value = value.as_object().get("inherited"); + if (value.as_object().has("inherited"sv)) { + auto& inherited_value = value.as_object().get("inherited"sv); VERIFY(inherited_value.is_bool()); inherited = inherited_value.as_bool(); } @@ -260,8 +260,8 @@ bool property_affects_layout(PropertyID property_id) VERIFY(value.is_object()); bool affects_layout = true; - if (value.as_object().has("affects-layout")) - affects_layout = value.as_object().get("affects-layout").to_bool(); + if (value.as_object().has("affects-layout"sv)) + affects_layout = value.as_object().get("affects-layout"sv).to_bool(); if (affects_layout) { auto member_generator = generator.fork(); @@ -288,8 +288,8 @@ bool property_affects_stacking_context(PropertyID property_id) VERIFY(value.is_object()); bool affects_stacking_context = false; - if (value.as_object().has("affects-stacking-context")) - affects_stacking_context = value.as_object().get("affects-stacking-context").to_bool(); + if (value.as_object().has("affects-stacking-context"sv)) + affects_stacking_context = value.as_object().get("affects-stacking-context"sv).to_bool(); if (affects_stacking_context) { auto member_generator = generator.fork(); @@ -322,11 +322,11 @@ NonnullRefPtr property_initial_value(PropertyID property_id) // works for now! :^) auto output_initial_value_code = [&](auto& name, auto& object) { - if (!object.has("initial")) { + if (!object.has("initial"sv)) { dbgln("No initial value specified for property '{}'", name); VERIFY_NOT_REACHED(); } - auto& initial_value = object.get("initial"); + auto& initial_value = object.get("initial"sv); VERIFY(initial_value.is_string()); auto initial_value_string = initial_value.as_string(); @@ -335,7 +335,7 @@ NonnullRefPtr property_initial_value(PropertyID property_id) member_generator.set("initial_value_string", initial_value_string); member_generator.append(R"~~~( { - auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@", PropertyID::@name:titlecase@); + auto parsed_value = parse_css_value(parsing_context, "@initial_value_string@"sv, PropertyID::@name:titlecase@); VERIFY(!parsed_value.is_null()); initial_values[to_underlying(PropertyID::@name:titlecase@)] = parsed_value.release_nonnull(); } @@ -344,14 +344,14 @@ NonnullRefPtr property_initial_value(PropertyID property_id) properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (value.as_object().has("longhands")) + if (value.as_object().has("longhands"sv)) return; output_initial_value_code(name, value.as_object()); }); properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (!value.as_object().has("longhands")) + if (!value.as_object().has("longhands"sv)) return; output_initial_value_code(name, value.as_object()); }); @@ -369,8 +369,8 @@ bool property_has_quirk(PropertyID property_id, Quirk quirk) properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (value.as_object().has("quirks")) { - auto& quirks_value = value.as_object().get("quirks"); + if (value.as_object().has("quirks"sv)) { + auto& quirks_value = value.as_object().get("quirks"sv); VERIFY(quirks_value.is_array()); auto& quirks = quirks_value.as_array(); @@ -417,8 +417,8 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value) properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); auto& object = value.as_object(); - bool has_valid_types = object.has("valid-types"); - auto has_valid_identifiers = object.has("valid-identifiers"); + bool has_valid_types = object.has("valid-types"sv); + auto has_valid_identifiers = object.has("valid-identifiers"sv); if (has_valid_types || has_valid_identifiers) { auto property_generator = generator.fork(); property_generator.set("name:titlecase", title_casify(name)); @@ -461,7 +461,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value) }; if (has_valid_types) { - auto valid_types_value = object.get("valid-types"); + auto valid_types_value = object.get("valid-types"sv); VERIFY(valid_types_value.is_array()); auto valid_types = valid_types_value.as_array(); if (!valid_types.is_empty()) { @@ -480,36 +480,36 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value) } if (type_name == "angle") { - output_numeric_value_check(property_generator, "is_angle", "as_angle().angle().to_degrees()", Array { "Angle"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "is_angle"sv, "as_angle().angle().to_degrees()"sv, Array { "Angle"sv }, min_value, max_value); } else if (type_name == "color") { property_generator.append(R"~~~( if (style_value.has_color()) return true; )~~~"); } else if (type_name == "frequency") { - output_numeric_value_check(property_generator, "is_frequency", "as_frequency().frequency().to_hertz()", Array { "Frequency"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "is_frequency"sv, "as_frequency().frequency().to_hertz()"sv, Array { "Frequency"sv }, min_value, max_value); } else if (type_name == "image") { property_generator.append(R"~~~( if (style_value.is_image()) return true; )~~~"); } else if (type_name == "integer") { - output_numeric_value_check(property_generator, "has_integer", "to_integer()", Array { "Integer"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "has_integer"sv, "to_integer()"sv, Array { "Integer"sv }, min_value, max_value); } else if (type_name == "length") { - output_numeric_value_check(property_generator, "has_length", "to_length().raw_value()", Array { "Length"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "has_length"sv, "to_length().raw_value()"sv, Array { "Length"sv }, min_value, max_value); } else if (type_name == "number") { - output_numeric_value_check(property_generator, "has_number", "to_number()", Array { "Integer"sv, "Number"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "has_number"sv, "to_number()"sv, Array { "Integer"sv, "Number"sv }, min_value, max_value); } else if (type_name == "percentage") { - output_numeric_value_check(property_generator, "is_percentage", "as_percentage().percentage().value()", Array { "Percentage"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "is_percentage"sv, "as_percentage().percentage().value()"sv, Array { "Percentage"sv }, min_value, max_value); } else if (type_name == "resolution") { - output_numeric_value_check(property_generator, "is_resolution", "as_resolution().resolution().to_dots_per_pixel()", Array {}, min_value, max_value); + output_numeric_value_check(property_generator, "is_resolution"sv, "as_resolution().resolution().to_dots_per_pixel()"sv, Array {}, min_value, max_value); } else if (type_name == "string") { property_generator.append(R"~~~( if (style_value.is_string()) return true; )~~~"); } else if (type_name == "time") { - output_numeric_value_check(property_generator, "is_time", "as_time().time().to_seconds()", Array { "Time"sv }, min_value, max_value); + output_numeric_value_check(property_generator, "is_time"sv, "as_time().time().to_seconds()"sv, Array { "Time"sv }, min_value, max_value); } else if (type_name == "url") { // FIXME: Handle urls! } else { @@ -526,7 +526,7 @@ bool property_accepts_value(PropertyID property_id, StyleValue& style_value) } if (has_valid_identifiers) { - auto valid_identifiers_value = object.get("valid-identifiers"); + auto valid_identifiers_value = object.get("valid-identifiers"sv); VERIFY(valid_identifiers_value.is_array()); auto valid_identifiers = valid_identifiers_value.as_array(); if (!valid_identifiers.is_empty()) { @@ -570,8 +570,8 @@ size_t property_maximum_value_count(PropertyID property_id) properties.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - if (value.as_object().has("max-values")) { - auto max_values = value.as_object().get("max-values"); + if (value.as_object().has("max-values"sv)) { + auto max_values = value.as_object().get("max-values"sv); VERIFY(max_values.is_number() && !max_values.is_double()); auto property_generator = generator.fork(); property_generator.set("name:titlecase", title_casify(name)); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp index ca36b2a5c55..7637c28877d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSTransformFunctions.cpp @@ -153,7 +153,7 @@ TransformFunctionMetadata transform_function_metadata(TransformFunction transfor )~~~"); transforms_data.for_each_member([&](auto& name, auto& value) { VERIFY(value.is_object()); - auto parameters_string = value.as_object().get("parameters").as_string(); + auto parameters_string = value.as_object().get("parameters"sv).as_string(); GenericLexer lexer { parameters_string }; VERIFY(lexer.consume_specific('<')); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp index e21d33f1d2d..29a30fea72d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSValueID.cpp @@ -98,7 +98,7 @@ ValueID value_id_from_string(StringView string) member_generator.set("name", name.to_string()); member_generator.set("name:titlecase", title_casify(name.to_string())); member_generator.append(R"~~~( - if (string.equals_ignoring_case("@name@")) + if (string.equals_ignoring_case("@name@"sv)) return ValueID::@name:titlecase@; )~~~"); }); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h index 209d23860a3..c1e6489f7b3 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GeneratorUtil.h @@ -51,7 +51,7 @@ String camel_casify(StringView dashy_name) String snake_casify(String const& dashy_name) { - return dashy_name.replace("-", "_", ReplaceMode::All); + return dashy_name.replace("-"sv, "_"sv, ReplaceMode::All); } ErrorOr read_entire_file_as_json(StringView filename) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp index ab54ab21e3f..1724b4b4a9d 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLGenerators.cpp @@ -28,9 +28,9 @@ static bool is_wrappable_type(Type const& type) return true; if (type.name == "DocumentType") return true; - if (type.name.ends_with("Element")) + if (type.name.ends_with("Element"sv)) return true; - if (type.name.ends_with("Event")) + if (type.name.ends_with("Event"sv)) return true; if (type.name == "ImageData") return true; @@ -155,7 +155,7 @@ static String make_input_acceptable_cpp(String const& input) return builder.to_string(); } - return input.replace("-", "_", ReplaceMode::All); + return input.replace("-"sv, "_"sv, ReplaceMode::All); } static void generate_include_for_wrapper(auto& generator, auto& wrapper_name) @@ -239,7 +239,7 @@ static void emit_includes_for_all_imports(auto& interface, auto& generator, bool if (is_iterator) { auto iterator_name = String::formatted("{}Iterator", interface->name); - auto iterator_path = String::formatted("{}Iterator", interface->fully_qualified_name.replace("::", "/", ReplaceMode::All)); + auto iterator_path = String::formatted("{}Iterator", interface->fully_qualified_name.replace("::"sv, "/"sv, ReplaceMode::All)); generate_include_for_iterator(generator, iterator_path, iterator_name); } @@ -263,9 +263,9 @@ static bool should_emit_wrapper_factory(IDL::Interface const& interface) return false; if (interface.name == "DocumentType") return false; - if (interface.name.ends_with("Element")) + if (interface.name.ends_with("Element"sv)) return false; - if (interface.name.starts_with("CSS") && interface.name.ends_with("Rule")) + if (interface.name.starts_with("CSS"sv) && interface.name.ends_with("Rule"sv)) return false; return true; } @@ -580,7 +580,7 @@ static void generate_to_cpp(SourceGenerator& generator, ParameterType& parameter auto default_value_cpp_name = enumeration.translated_cpp_names.get(enum_member_name); VERIFY(default_value_cpp_name.has_value()); enum_generator.set("enum.default.cpp_value", *default_value_cpp_name); - enum_generator.set("js_name.as_string", String::formatted("{}{}_string", enum_generator.get("js_name"), enum_generator.get("js_suffix"))); + enum_generator.set("js_name.as_string", String::formatted("{}{}_string", enum_generator.get("js_name"sv), enum_generator.get("js_suffix"sv))); enum_generator.append(R"~~~( @parameter.type.name@ @cpp_name@ { @parameter.type.name@::@enum.default.cpp_value@ }; )~~~"); @@ -1291,7 +1291,7 @@ static void generate_arguments(SourceGenerator& generator, Vector generate_arguments_match_check_for_count(Vector diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp index 15083ce0d95..5efec6dd32a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLParser.cpp @@ -40,7 +40,7 @@ error_message.appendff("{}\n", input.substring_view(start_line, line_length)); for (size_t i = 0; i < colno - 1; ++i) error_message.append(' '); - error_message.append("\033[1;31m^\n"); + error_message.append("\033[1;31m^\n"sv); error_message.appendff("{}:{}: error: {}\033[0m\n", filename, lineno, message); warnln("{}", error_message.string_view()); @@ -65,7 +65,7 @@ static String convert_enumeration_value_to_cpp_enum_member(String const& value, } if (builder.is_empty()) - builder.append("Empty"); + builder.append("Empty"sv); while (names_already_seen.contains(builder.string_view())) builder.append('_'); @@ -158,7 +158,7 @@ NonnullRefPtr Parser::parse_type() NonnullRefPtrVector union_member_types; union_member_types.append(parse_type()); consume_whitespace(); - assert_string("or"); + assert_string("or"sv); consume_whitespace(); union_member_types.append(parse_type()); consume_whitespace(); @@ -185,7 +185,7 @@ NonnullRefPtr Parser::parse_type() if (name.equals_ignoring_case("long"sv)) { consume_whitespace(); if (lexer.consume_specific("long"sv)) - name = "long long"; + name = "long long"sv; } NonnullRefPtrVector parameters; @@ -202,7 +202,7 @@ NonnullRefPtr Parser::parse_type() auto nullable = lexer.consume_specific('?'); StringBuilder builder; if (unsigned_) - builder.append("unsigned "); + builder.append("unsigned "sv); builder.append(name); if (is_parameterized_type) @@ -341,7 +341,7 @@ Function Parser::parse_function(HashMap& extended_attributes, In void Parser::parse_constructor(Interface& interface) { - assert_string("constructor"); + assert_string("constructor"sv); consume_whitespace(); assert_specific('('); auto parameters = parse_parameters(); @@ -354,10 +354,10 @@ void Parser::parse_constructor(Interface& interface) void Parser::parse_stringifier(HashMap& extended_attributes, Interface& interface) { - assert_string("stringifier"); + assert_string("stringifier"sv); consume_whitespace(); interface.has_stringifier = true; - if (lexer.next_is("readonly") || lexer.next_is("attribute")) { + if (lexer.next_is("readonly"sv) || lexer.next_is("attribute"sv)) { parse_attribute(extended_attributes, interface); interface.stringifier_attribute = interface.attributes.last().name; } else { @@ -367,12 +367,12 @@ void Parser::parse_stringifier(HashMap& extended_attributes, Int void Parser::parse_iterable(Interface& interface) { - assert_string("iterable"); + assert_string("iterable"sv); assert_specific('<'); auto first_type = parse_type(); if (lexer.next_is(',')) { if (interface.supports_indexed_properties()) - report_parsing_error("Interfaces with a pair iterator must not supported indexed properties.", filename, input, lexer.tell()); + report_parsing_error("Interfaces with a pair iterator must not supported indexed properties."sv, filename, input, lexer.tell()); assert_specific(','); consume_whitespace(); @@ -380,7 +380,7 @@ void Parser::parse_iterable(Interface& interface) interface.pair_iterator_types = Tuple { move(first_type), move(second_type) }; } else { if (!interface.supports_indexed_properties()) - report_parsing_error("Interfaces with a value iterator must supported indexed properties.", filename, input, lexer.tell()); + report_parsing_error("Interfaces with a value iterator must supported indexed properties."sv, filename, input, lexer.tell()); interface.value_iterator_type = move(first_type); } @@ -390,7 +390,7 @@ void Parser::parse_iterable(Interface& interface) void Parser::parse_getter(HashMap& extended_attributes, Interface& interface) { - assert_string("getter"); + assert_string("getter"sv); consume_whitespace(); auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes); @@ -400,21 +400,21 @@ void Parser::parse_getter(HashMap& extended_attributes, Interfac auto& identifier = function.parameters.first(); if (identifier.type->nullable) - report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell()); + report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell()); if (identifier.optional) - report_parsing_error("identifier must not be optional.", filename, input, lexer.tell()); + report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell()); // FIXME: Disallow variadic functions once they're supported. if (identifier.type->name == "DOMString") { if (interface.named_property_getter.has_value()) - report_parsing_error("An interface can only have one named property getter.", filename, input, lexer.tell()); + report_parsing_error("An interface can only have one named property getter."sv, filename, input, lexer.tell()); interface.named_property_getter = move(function); } else if (identifier.type->name == "unsigned long") { if (interface.indexed_property_getter.has_value()) - report_parsing_error("An interface can only have one indexed property getter.", filename, input, lexer.tell()); + report_parsing_error("An interface can only have one indexed property getter."sv, filename, input, lexer.tell()); interface.indexed_property_getter = move(function); } else { @@ -424,7 +424,7 @@ void Parser::parse_getter(HashMap& extended_attributes, Interfac void Parser::parse_setter(HashMap& extended_attributes, Interface& interface) { - assert_string("setter"); + assert_string("setter"sv); consume_whitespace(); auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes); @@ -434,27 +434,27 @@ void Parser::parse_setter(HashMap& extended_attributes, Interfac auto& identifier = function.parameters.first(); if (identifier.type->nullable) - report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell()); + report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell()); if (identifier.optional) - report_parsing_error("identifier must not be optional.", filename, input, lexer.tell()); + report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell()); // FIXME: Disallow variadic functions once they're supported. if (identifier.type->name == "DOMString") { if (interface.named_property_setter.has_value()) - report_parsing_error("An interface can only have one named property setter.", filename, input, lexer.tell()); + report_parsing_error("An interface can only have one named property setter."sv, filename, input, lexer.tell()); if (!interface.named_property_getter.has_value()) - report_parsing_error("A named property setter must be accompanied by a named property getter.", filename, input, lexer.tell()); + report_parsing_error("A named property setter must be accompanied by a named property getter."sv, filename, input, lexer.tell()); interface.named_property_setter = move(function); } else if (identifier.type->name == "unsigned long") { if (interface.indexed_property_setter.has_value()) - report_parsing_error("An interface can only have one indexed property setter.", filename, input, lexer.tell()); + report_parsing_error("An interface can only have one indexed property setter."sv, filename, input, lexer.tell()); if (!interface.indexed_property_getter.has_value()) - report_parsing_error("An indexed property setter must be accompanied by an indexed property getter.", filename, input, lexer.tell()); + report_parsing_error("An indexed property setter must be accompanied by an indexed property getter."sv, filename, input, lexer.tell()); interface.indexed_property_setter = move(function); } else { @@ -464,7 +464,7 @@ void Parser::parse_setter(HashMap& extended_attributes, Interfac void Parser::parse_deleter(HashMap& extended_attributes, Interface& interface) { - assert_string("deleter"); + assert_string("deleter"sv); consume_whitespace(); auto function = parse_function(extended_attributes, interface, IsSpecialOperation::Yes); @@ -474,19 +474,19 @@ void Parser::parse_deleter(HashMap& extended_attributes, Interfa auto& identifier = function.parameters.first(); if (identifier.type->nullable) - report_parsing_error("identifier's type must not be nullable.", filename, input, lexer.tell()); + report_parsing_error("identifier's type must not be nullable."sv, filename, input, lexer.tell()); if (identifier.optional) - report_parsing_error("identifier must not be optional.", filename, input, lexer.tell()); + report_parsing_error("identifier must not be optional."sv, filename, input, lexer.tell()); // FIXME: Disallow variadic functions once they're supported. if (identifier.type->name == "DOMString") { if (interface.named_property_deleter.has_value()) - report_parsing_error("An interface can only have one named property deleter.", filename, input, lexer.tell()); + report_parsing_error("An interface can only have one named property deleter."sv, filename, input, lexer.tell()); if (!interface.named_property_getter.has_value()) - report_parsing_error("A named property deleter must be accompanied by a named property getter.", filename, input, lexer.tell()); + report_parsing_error("A named property deleter must be accompanied by a named property getter."sv, filename, input, lexer.tell()); interface.named_property_deleter = move(function); } else { @@ -576,7 +576,7 @@ void Parser::parse_interface(Interface& interface) void Parser::parse_enumeration(Interface& interface) { - assert_string("enum"); + assert_string("enum"sv); consume_whitespace(); Enumeration enumeration {}; @@ -626,7 +626,7 @@ void Parser::parse_enumeration(Interface& interface) void Parser::parse_typedef(Interface& interface) { - assert_string("typedef"); + assert_string("typedef"sv); consume_whitespace(); HashMap extended_attributes; @@ -645,7 +645,7 @@ void Parser::parse_typedef(Interface& interface) void Parser::parse_dictionary(Interface& interface) { - assert_string("dictionary"); + assert_string("dictionary"sv); consume_whitespace(); Dictionary dictionary {}; @@ -723,14 +723,14 @@ void Parser::parse_interface_mixin(Interface& interface) mixin_interface.module_own_path = interface.module_own_path; mixin_interface.is_mixin = true; - assert_string("interface"); + assert_string("interface"sv); consume_whitespace(); - assert_string("mixin"); + assert_string("mixin"sv); auto offset = lexer.tell(); parse_interface(mixin_interface); if (!mixin_interface.parent_name.is_empty()) - report_parsing_error("Mixin interfaces are not allowed to have inherited parents", filename, input, offset); + report_parsing_error("Mixin interfaces are not allowed to have inherited parents"sv, filename, input, offset); auto name = mixin_interface.name; interface.mixins.set(move(name), &mixin_interface); @@ -738,7 +738,7 @@ void Parser::parse_interface_mixin(Interface& interface) void Parser::parse_callback_function(HashMap& extended_attributes, Interface& interface) { - assert_string("callback"); + assert_string("callback"sv); consume_whitespace(); auto name = lexer.consume_until([](auto ch) { return is_ascii_space(ch); }); @@ -787,7 +787,7 @@ void Parser::parse_non_interface_entities(bool allow_interface, Interface& inter assert_specific(';'); consume_whitespace(); } else { - report_parsing_error("expected 'enum' or 'dictionary'", filename, input, current_offset); + report_parsing_error("expected 'enum' or 'dictionary'"sv, filename, input, current_offset); } } else { interface.extended_attributes = move(extended_attributes); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h index 88de8e33742..12b9becd035 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/IDLTypes.h @@ -340,21 +340,21 @@ struct UnionType : public Type { String to_variant(IDL::Interface const& interface) const { StringBuilder builder; - builder.append("Variant<"); + builder.append("Variant<"sv); auto flattened_types = flattened_member_types(); for (size_t type_index = 0; type_index < flattened_types.size(); ++type_index) { auto& type = flattened_types.at(type_index); if (type_index > 0) - builder.append(", "); + builder.append(", "sv); auto cpp_type = idl_type_name_to_cpp_type(type, interface); builder.append(cpp_type.name); } if (includes_undefined()) - builder.append(", Empty"); + builder.append(", Empty"sv); builder.append('>'); return builder.to_string(); diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/main.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/main.cpp index a641334f06b..770b9f2735a 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/main.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/WrapperGenerator/main.cpp @@ -88,7 +88,7 @@ int main(int argc, char** argv) if (namespace_.is_one_of("Crypto", "CSS", "DOM", "DOMParsing", "Encoding", "HTML", "UIEvents", "Geometry", "HighResolutionTime", "IntersectionObserver", "NavigationTiming", "RequestIdleCallback", "ResizeObserver", "SVG", "Selection", "URL", "WebGL", "WebSockets", "XHR")) { StringBuilder builder; builder.append(namespace_); - builder.append("::"); + builder.append("::"sv); builder.append(interface.name); interface.fully_qualified_name = builder.to_string(); } else { diff --git a/Meta/Lagom/Tools/ConfigureComponents/main.cpp b/Meta/Lagom/Tools/ConfigureComponents/main.cpp index c09dedbe61b..be1464a10f5 100644 --- a/Meta/Lagom/Tools/ConfigureComponents/main.cpp +++ b/Meta/Lagom/Tools/ConfigureComponents/main.cpp @@ -200,7 +200,7 @@ static Result, int> run_whiptail(WhiptailMode mode, Vector" +echo +echo "extern StringView $1;" +printf "StringView %s = R\"~~~(" "$1" grep -v '^ *#' < "$2" | while IFS= read -r line; do echo "$line" done -echo ")~~~\";" +echo ")~~~\"sv;" diff --git a/Tests/AK/TestFormat.cpp b/Tests/AK/TestFormat.cpp index 29c922316d7..6ba944312b6 100644 --- a/Tests/AK/TestFormat.cpp +++ b/Tests/AK/TestFormat.cpp @@ -204,7 +204,7 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, B) { - return Formatter::format(builder, "B"); + return Formatter::format(builder, "B"sv); } }; @@ -288,7 +288,7 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, C c) { - return AK::Formatter::format(builder, "C(i={})", c.i); + return AK::Formatter::format(builder, "C(i={})"sv, c.i); } }; diff --git a/Tests/AK/TestIPv4Address.cpp b/Tests/AK/TestIPv4Address.cpp index 094b1a7253c..48c27ee811c 100644 --- a/Tests/AK/TestIPv4Address.cpp +++ b/Tests/AK/TestIPv4Address.cpp @@ -66,7 +66,7 @@ TEST_CASE(should_convert_to_string) TEST_CASE(should_make_ipv4_address_from_string) { - auto const addr = IPv4Address::from_string("192.168.0.1"); + auto const addr = IPv4Address::from_string("192.168.0.1"sv); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); @@ -77,21 +77,21 @@ TEST_CASE(should_make_ipv4_address_from_string) TEST_CASE(should_make_empty_optional_from_bad_string) { - auto const addr = IPv4Address::from_string("bad string"); + auto const addr = IPv4Address::from_string("bad string"sv); EXPECT(!addr.has_value()); } TEST_CASE(should_make_empty_optional_from_out_of_range_values) { - auto const addr = IPv4Address::from_string("192.168.0.500"); + auto const addr = IPv4Address::from_string("192.168.0.500"sv); EXPECT(!addr.has_value()); } TEST_CASE(should_fill_d_octet_from_1_part) { - auto const addr = IPv4Address::from_string("1"); + auto const addr = IPv4Address::from_string("1"sv); EXPECT(addr.has_value()); EXPECT_EQ(0, addr.value()[0]); @@ -102,7 +102,7 @@ TEST_CASE(should_fill_d_octet_from_1_part) TEST_CASE(should_fill_a_and_d_octets_from_2_parts) { - auto const addr = IPv4Address::from_string("192.1"); + auto const addr = IPv4Address::from_string("192.1"sv); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); @@ -113,7 +113,7 @@ TEST_CASE(should_fill_a_and_d_octets_from_2_parts) TEST_CASE(should_fill_a_b_d_octets_from_3_parts) { - auto const addr = IPv4Address::from_string("192.168.1"); + auto const addr = IPv4Address::from_string("192.168.1"sv); EXPECT(addr.has_value()); EXPECT_EQ(192, addr.value()[0]); diff --git a/Tests/AK/TestJSON.cpp b/Tests/AK/TestJSON.cpp index c55d21ed662..ff887fe9d52 100644 --- a/Tests/AK/TestJSON.cpp +++ b/Tests/AK/TestJSON.cpp @@ -40,15 +40,15 @@ TEST_CASE(load_form) EXPECT(form_json.is_object()); - auto name = form_json.as_object().get("name").to_string(); + auto name = form_json.as_object().get("name"sv).to_string(); EXPECT_EQ(name, "Form1"); - auto widgets = form_json.as_object().get("widgets").as_array(); + auto widgets = form_json.as_object().get("widgets"sv).as_array(); widgets.for_each([&](JsonValue const& widget_value) { auto& widget_object = widget_value.as_object(); - auto widget_class = widget_object.get("class").as_string(); + auto widget_class = widget_object.get("class"sv).as_string(); widget_object.for_each_member([&]([[maybe_unused]] auto& property_name, [[maybe_unused]] const JsonValue& property_value) { }); }); @@ -56,7 +56,7 @@ TEST_CASE(load_form) TEST_CASE(json_empty_string) { - auto json = JsonValue::from_string("\"\"").value(); + auto json = JsonValue::from_string("\"\""sv).value(); EXPECT_EQ(json.type(), JsonValue::Type::String); EXPECT_EQ(json.as_string().is_null(), false); EXPECT_EQ(json.as_string().is_empty(), true); @@ -64,7 +64,7 @@ TEST_CASE(json_empty_string) TEST_CASE(json_string) { - auto json = JsonValue::from_string("\"A\"").value(); + auto json = JsonValue::from_string("\"A\""sv).value(); EXPECT_EQ(json.type(), JsonValue::Type::String); EXPECT_EQ(json.as_string().is_null(), false); EXPECT_EQ(json.as_string().length(), size_t { 1 }); @@ -73,7 +73,7 @@ TEST_CASE(json_string) TEST_CASE(json_utf8_character) { - auto json = JsonValue::from_string("\"\\u0041\"").value(); + auto json = JsonValue::from_string("\"\\u0041\""sv).value(); EXPECT_EQ(json.type(), JsonValue::Type::String); EXPECT_EQ(json.as_string().is_null(), false); EXPECT_EQ(json.as_string().length(), size_t { 1 }); @@ -125,12 +125,12 @@ TEST_CASE(json_u64_roundtrip) TEST_CASE(json_parse_empty_string) { - auto value = JsonValue::from_string(""); + auto value = JsonValue::from_string(""sv); EXPECT_EQ(value.is_error(), true); } TEST_CASE(json_parse_long_decimals) { - auto value = JsonValue::from_string("1644452550.6489999294281"); + auto value = JsonValue::from_string("1644452550.6489999294281"sv); EXPECT_EQ(value.value().as_double(), 1644452550.6489999294281); } diff --git a/Tests/AK/TestLexicalPath.cpp b/Tests/AK/TestLexicalPath.cpp index f4959f73f3c..e1443b9665b 100644 --- a/Tests/AK/TestLexicalPath.cpp +++ b/Tests/AK/TestLexicalPath.cpp @@ -12,13 +12,13 @@ TEST_CASE(relative_path) { - EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt", "/tmp"), "abc.txt"); - EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt", "/tmp/"), "abc.txt"); - EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt", "/"), "tmp/abc.txt"); - EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt", "/usr"), "/tmp/abc.txt"); + EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/tmp"sv), "abc.txt"sv); + EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/tmp/"sv), "abc.txt"sv); + EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/"sv), "tmp/abc.txt"sv); + EXPECT_EQ(LexicalPath::relative_path("/tmp/abc.txt"sv, "/usr"sv), "/tmp/abc.txt"sv); - EXPECT_EQ(LexicalPath::relative_path("/tmp/foo.txt", "tmp"), String {}); - EXPECT_EQ(LexicalPath::relative_path("tmp/foo.txt", "/tmp"), String {}); + EXPECT_EQ(LexicalPath::relative_path("/tmp/foo.txt"sv, "tmp"sv), ""sv); + EXPECT_EQ(LexicalPath::relative_path("tmp/foo.txt"sv, "/tmp"sv), ""sv); } TEST_CASE(regular_absolute_path) @@ -29,9 +29,9 @@ TEST_CASE(regular_absolute_path) EXPECT_EQ(path.basename(), "foo.txt"); EXPECT_EQ(path.title(), "foo"); EXPECT_EQ(path.extension(), "txt"); - EXPECT(path.has_extension(".txt")); - EXPECT(path.has_extension("txt")); - EXPECT(!path.has_extension("txxt")); + EXPECT(path.has_extension(".txt"sv)); + EXPECT(path.has_extension("txt"sv)); + EXPECT(!path.has_extension("txxt"sv)); EXPECT_EQ(path.parts_view().size(), 3u); EXPECT_EQ(path.parts_view()[0], "home"); EXPECT_EQ(path.parts_view()[1], "anon"); @@ -145,41 +145,41 @@ TEST_CASE(has_extension) { { LexicalPath path("/tmp/simple.png"); - EXPECT(path.has_extension(".png")); - EXPECT(path.has_extension(".pnG")); - EXPECT(path.has_extension(".PNG")); + EXPECT(path.has_extension(".png"sv)); + EXPECT(path.has_extension(".pnG"sv)); + EXPECT(path.has_extension(".PNG"sv)); } { LexicalPath path("/TMP/SIMPLE.PNG"); - EXPECT(path.has_extension(".png")); - EXPECT(path.has_extension(".pnG")); - EXPECT(path.has_extension(".PNG")); + EXPECT(path.has_extension(".png"sv)); + EXPECT(path.has_extension(".pnG"sv)); + EXPECT(path.has_extension(".PNG"sv)); } { LexicalPath path(".png"); - EXPECT(path.has_extension(".png")); + EXPECT(path.has_extension(".png"sv)); } { LexicalPath path("png"); - EXPECT_EQ(path.has_extension(".png"), false); + EXPECT_EQ(path.has_extension(".png"sv), false); } } TEST_CASE(join) { - EXPECT_EQ(LexicalPath::join("anon", "foo.txt").string(), "anon/foo.txt"); - EXPECT_EQ(LexicalPath::join("/home", "anon/foo.txt").string(), "/home/anon/foo.txt"); - EXPECT_EQ(LexicalPath::join("/", "foo.txt").string(), "/foo.txt"); - EXPECT_EQ(LexicalPath::join("/home", "anon", "foo.txt").string(), "/home/anon/foo.txt"); + EXPECT_EQ(LexicalPath::join("anon"sv, "foo.txt"sv).string(), "anon/foo.txt"sv); + EXPECT_EQ(LexicalPath::join("/home"sv, "anon/foo.txt"sv).string(), "/home/anon/foo.txt"sv); + EXPECT_EQ(LexicalPath::join("/"sv, "foo.txt"sv).string(), "/foo.txt"sv); + EXPECT_EQ(LexicalPath::join("/home"sv, "anon"sv, "foo.txt"sv).string(), "/home/anon/foo.txt"sv); } TEST_CASE(append) { LexicalPath path("/home/anon/"); - auto new_path = path.append("foo.txt"); + auto new_path = path.append("foo.txt"sv); EXPECT_EQ(new_path.string(), "/home/anon/foo.txt"); } diff --git a/Tests/AK/TestMACAddress.cpp b/Tests/AK/TestMACAddress.cpp index 55767f85519..eac35bb97ab 100644 --- a/Tests/AK/TestMACAddress.cpp +++ b/Tests/AK/TestMACAddress.cpp @@ -85,7 +85,7 @@ TEST_CASE(should_string_format) TEST_CASE(should_make_mac_address_from_string_numbers) { - auto const sut = MACAddress::from_string("01:02:03:04:05:06"); + auto const sut = MACAddress::from_string("01:02:03:04:05:06"sv); EXPECT(sut.has_value()); EXPECT_EQ(1, sut.value()[0]); @@ -98,7 +98,7 @@ TEST_CASE(should_make_mac_address_from_string_numbers) TEST_CASE(should_make_mac_address_from_string_letters) { - auto const sut = MACAddress::from_string("de:ad:be:ee:ee:ef"); + auto const sut = MACAddress::from_string("de:ad:be:ee:ee:ef"sv); EXPECT(sut.has_value()); EXPECT_EQ(u8 { 0xDE }, sut.value()[0]); @@ -111,14 +111,14 @@ TEST_CASE(should_make_mac_address_from_string_letters) TEST_CASE(should_make_empty_optional_from_bad_string) { - auto const sut = MACAddress::from_string("bad string"); + auto const sut = MACAddress::from_string("bad string"sv); EXPECT(!sut.has_value()); } TEST_CASE(should_make_empty_optional_from_out_of_range_values) { - auto const sut = MACAddress::from_string("de:ad:be:ee:ee:fz"); + auto const sut = MACAddress::from_string("de:ad:be:ee:ee:fz"sv); EXPECT(!sut.has_value()); } diff --git a/Tests/AK/TestOptional.cpp b/Tests/AK/TestOptional.cpp index 723d3dd74b3..23bf3e7491d 100644 --- a/Tests/AK/TestOptional.cpp +++ b/Tests/AK/TestOptional.cpp @@ -71,7 +71,7 @@ TEST_CASE(optional_leak_1) TEST_CASE(short_notation) { - Optional value = "foo"; + Optional value = "foo"sv; EXPECT_EQ(value->length(), 3u); EXPECT_EQ(*value, "foo"); @@ -89,9 +89,9 @@ TEST_CASE(comparison_without_values) TEST_CASE(comparison_with_values) { Optional opt0; - Optional opt1 = "foo"; - Optional opt2 = "foo"; - Optional opt3 = "bar"; + Optional opt1 = "foo"sv; + Optional opt2 = "foo"sv; + Optional opt3 = "bar"sv; EXPECT_NE(opt0, opt1); EXPECT_EQ(opt1, opt2); EXPECT_NE(opt1, opt3); @@ -103,7 +103,7 @@ TEST_CASE(comparison_to_underlying_types) EXPECT_NE(opt0, String()); EXPECT_NE(opt0, "foo"); - Optional opt1 = "foo"; + Optional opt1 = "foo"sv; EXPECT_EQ(opt1, "foo"); EXPECT_NE(opt1, "bar"); EXPECT_EQ(opt1, String("foo")); @@ -250,7 +250,7 @@ TEST_CASE(move_optional_reference) TEST_CASE(short_notation_reference) { - StringView test = "foo"; + StringView test = "foo"sv; Optional value = test; EXPECT_EQ(value->length(), 3u); @@ -259,11 +259,11 @@ TEST_CASE(short_notation_reference) TEST_CASE(comparison_reference) { - StringView test = "foo"; + StringView test = "foo"sv; Optional opt0; Optional opt1 = test; - Optional opt2 = "foo"; - Optional opt3 = "bar"; + Optional opt2 = "foo"sv; + Optional opt3 = "bar"sv; EXPECT_NE(opt0, opt1); EXPECT_EQ(opt1, opt2); diff --git a/Tests/AK/TestString.cpp b/Tests/AK/TestString.cpp index 2c059f4af3f..520ed872e80 100644 --- a/Tests/AK/TestString.cpp +++ b/Tests/AK/TestString.cpp @@ -47,14 +47,14 @@ TEST_CASE(equal) TEST_CASE(compare) { - EXPECT("a" < String("b")); - EXPECT(!("a" > String("b"))); - EXPECT("b" > String("a")); - EXPECT(!("b" < String("b"))); - EXPECT("a" >= String("a")); - EXPECT(!("a" >= String("b"))); - EXPECT("a" <= String("a")); - EXPECT(!("b" <= String("a"))); + EXPECT("a"sv < String("b")); + EXPECT(!("a"sv > String("b"))); + EXPECT("b"sv > String("a")); + EXPECT(!("b"sv < String("b"))); + EXPECT("a"sv >= String("a")); + EXPECT(!("a"sv >= String("b"))); + EXPECT("a"sv <= String("a")); + EXPECT(!("b"sv <= String("a"))); EXPECT(String("a") > String()); EXPECT(!(String() > String("a"))); @@ -81,25 +81,25 @@ TEST_CASE(index_access) TEST_CASE(starts_with) { String test_string = "ABCDEF"; - EXPECT(test_string.starts_with("AB")); + EXPECT(test_string.starts_with("AB"sv)); EXPECT(test_string.starts_with('A')); EXPECT(!test_string.starts_with('B')); - EXPECT(test_string.starts_with("ABCDEF")); - EXPECT(!test_string.starts_with("DEF")); - EXPECT(test_string.starts_with("abc", CaseSensitivity::CaseInsensitive)); - EXPECT(!test_string.starts_with("abc", CaseSensitivity::CaseSensitive)); + EXPECT(test_string.starts_with("ABCDEF"sv)); + EXPECT(!test_string.starts_with("DEF"sv)); + EXPECT(test_string.starts_with("abc"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string.starts_with("abc"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(ends_with) { String test_string = "ABCDEF"; - EXPECT(test_string.ends_with("EF")); + EXPECT(test_string.ends_with("EF"sv)); EXPECT(test_string.ends_with('F')); EXPECT(!test_string.ends_with('E')); - EXPECT(test_string.ends_with("ABCDEF")); - EXPECT(!test_string.ends_with("ABC")); - EXPECT(test_string.ends_with("def", CaseSensitivity::CaseInsensitive)); - EXPECT(!test_string.ends_with("def", CaseSensitivity::CaseSensitive)); + EXPECT(test_string.ends_with("ABCDEF"sv)); + EXPECT(!test_string.ends_with("ABC"sv)); + EXPECT(test_string.ends_with("def"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string.ends_with("def"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(copy_string) @@ -155,7 +155,7 @@ TEST_CASE(flystring) FlyString b = a; StringBuilder builder; builder.append('f'); - builder.append("oo"); + builder.append("oo"sv); FlyString c = builder.to_string(); EXPECT_EQ(a.impl(), b.impl()); EXPECT_EQ(a.impl(), c.impl()); @@ -166,40 +166,40 @@ TEST_CASE(replace) { String test_string = "Well, hello Friends!"; - test_string = test_string.replace("Friends", "Testers", ReplaceMode::FirstOnly); + test_string = test_string.replace("Friends"sv, "Testers"sv, ReplaceMode::FirstOnly); EXPECT(test_string == "Well, hello Testers!"); - test_string = test_string.replace("ell", "e're", ReplaceMode::All); + test_string = test_string.replace("ell"sv, "e're"sv, ReplaceMode::All); EXPECT(test_string == "We're, he'reo Testers!"); - test_string = test_string.replace("!", " :^)", ReplaceMode::FirstOnly); + test_string = test_string.replace("!"sv, " :^)"sv, ReplaceMode::FirstOnly); EXPECT(test_string == "We're, he'reo Testers :^)"); test_string = String("111._.111._.111"); - test_string = test_string.replace("111", "|||", ReplaceMode::All); + test_string = test_string.replace("111"sv, "|||"sv, ReplaceMode::All); EXPECT(test_string == "|||._.|||._.|||"); - test_string = test_string.replace("|||", "111", ReplaceMode::FirstOnly); + test_string = test_string.replace("|||"sv, "111"sv, ReplaceMode::FirstOnly); EXPECT(test_string == "111._.|||._.|||"); } TEST_CASE(count) { String test_string = "Well, hello Friends!"; - u32 count = test_string.count("Friends"); + u32 count = test_string.count("Friends"sv); EXPECT(count == 1); - count = test_string.count("ell"); + count = test_string.count("ell"sv); EXPECT(count == 2); - count = test_string.count("!"); + count = test_string.count("!"sv); EXPECT(count == 1); test_string = String("111._.111._.111"); - count = test_string.count("111"); + count = test_string.count("111"sv); EXPECT(count == 3); - count = test_string.count("._."); + count = test_string.count("._."sv); EXPECT(count == 2); } @@ -251,7 +251,7 @@ TEST_CASE(split) TEST_CASE(builder_zero_initial_capacity) { StringBuilder builder(0); - builder.append(""); + builder.append(""sv); auto built = builder.build(); EXPECT_EQ(built.is_null(), false); EXPECT_EQ(built.length(), 0u); diff --git a/Tests/AK/TestStringUtils.cpp b/Tests/AK/TestStringUtils.cpp index b82a73886d9..356024ce071 100644 --- a/Tests/AK/TestStringUtils.cpp +++ b/Tests/AK/TestStringUtils.cpp @@ -13,67 +13,67 @@ TEST_CASE(matches_null) { EXPECT(AK::StringUtils::matches(StringView(), StringView())); - EXPECT(!AK::StringUtils::matches(StringView(), "")); - EXPECT(!AK::StringUtils::matches(StringView(), "*")); - EXPECT(!AK::StringUtils::matches(StringView(), "?")); - EXPECT(!AK::StringUtils::matches(StringView(), "a")); + EXPECT(!AK::StringUtils::matches(StringView(), ""sv)); + EXPECT(!AK::StringUtils::matches(StringView(), "*"sv)); + EXPECT(!AK::StringUtils::matches(StringView(), "?"sv)); + EXPECT(!AK::StringUtils::matches(StringView(), "a"sv)); - EXPECT(!AK::StringUtils::matches("", StringView())); - EXPECT(!AK::StringUtils::matches("a", StringView())); + EXPECT(!AK::StringUtils::matches(""sv, StringView())); + EXPECT(!AK::StringUtils::matches("a"sv, StringView())); } TEST_CASE(matches_empty) { - EXPECT(AK::StringUtils::matches("", "")); + EXPECT(AK::StringUtils::matches(""sv, ""sv)); - EXPECT(AK::StringUtils::matches("", "*")); - EXPECT(!AK::StringUtils::matches("", "?")); - EXPECT(!AK::StringUtils::matches("", "a")); + EXPECT(AK::StringUtils::matches(""sv, "*"sv)); + EXPECT(!AK::StringUtils::matches(""sv, "?"sv)); + EXPECT(!AK::StringUtils::matches(""sv, "a"sv)); - EXPECT(!AK::StringUtils::matches("a", "")); + EXPECT(!AK::StringUtils::matches("a"sv, ""sv)); } TEST_CASE(matches_case_sensitive) { - EXPECT(AK::StringUtils::matches("a", "a", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::matches("a", "A", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::matches("A", "a", CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::matches("a"sv, "a"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::matches("a"sv, "A"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::matches("A"sv, "a"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(matches_case_insensitive) { - EXPECT(!AK::StringUtils::matches("aa", "a")); - EXPECT(AK::StringUtils::matches("aa", "*")); - EXPECT(!AK::StringUtils::matches("cb", "?a")); - EXPECT(AK::StringUtils::matches("adceb", "a*b")); - EXPECT(!AK::StringUtils::matches("acdcb", "a*c?b")); + EXPECT(!AK::StringUtils::matches("aa"sv, "a"sv)); + EXPECT(AK::StringUtils::matches("aa"sv, "*"sv)); + EXPECT(!AK::StringUtils::matches("cb"sv, "?a"sv)); + EXPECT(AK::StringUtils::matches("adceb"sv, "a*b"sv)); + EXPECT(!AK::StringUtils::matches("acdcb"sv, "a*c?b"sv)); } TEST_CASE(matches_with_positions) { Vector spans; - EXPECT(AK::StringUtils::matches("abbb", "a*", CaseSensitivity::CaseSensitive, &spans)); + EXPECT(AK::StringUtils::matches("abbb"sv, "a*"sv, CaseSensitivity::CaseSensitive, &spans)); EXPECT(spans == Vector({ { 1, 3 } })); spans.clear(); - EXPECT(AK::StringUtils::matches("abbb", "?*", CaseSensitivity::CaseSensitive, &spans)); + EXPECT(AK::StringUtils::matches("abbb"sv, "?*"sv, CaseSensitivity::CaseSensitive, &spans)); EXPECT_EQ(spans, Vector({ { 0, 1 }, { 1, 3 } })); spans.clear(); - EXPECT(AK::StringUtils::matches("acdcxb", "a*c?b", CaseSensitivity::CaseSensitive, &spans)); + EXPECT(AK::StringUtils::matches("acdcxb"sv, "a*c?b"sv, CaseSensitivity::CaseSensitive, &spans)); EXPECT_EQ(spans, Vector({ { 1, 2 }, { 4, 1 } })); spans.clear(); - EXPECT(AK::StringUtils::matches("aaaa", "A*", CaseSensitivity::CaseInsensitive, &spans)); + EXPECT(AK::StringUtils::matches("aaaa"sv, "A*"sv, CaseSensitivity::CaseInsensitive, &spans)); EXPECT_EQ(spans, Vector({ { 1, 3 } })); } // #4607 TEST_CASE(matches_trailing) { - EXPECT(AK::StringUtils::matches("ab", "ab*")); - EXPECT(AK::StringUtils::matches("ab", "ab****")); - EXPECT(AK::StringUtils::matches("ab", "*ab****")); + EXPECT(AK::StringUtils::matches("ab"sv, "ab*"sv)); + EXPECT(AK::StringUtils::matches("ab"sv, "ab****"sv)); + EXPECT(AK::StringUtils::matches("ab"sv, "*ab****"sv)); } TEST_CASE(convert_to_int) @@ -81,76 +81,76 @@ TEST_CASE(convert_to_int) auto value = AK::StringUtils::convert_to_int(StringView()); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_int(""); + value = AK::StringUtils::convert_to_int(""sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_int("a"); + value = AK::StringUtils::convert_to_int("a"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_int("+"); + value = AK::StringUtils::convert_to_int("+"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_int("-"); + value = AK::StringUtils::convert_to_int("-"sv); EXPECT(!value.has_value()); - auto actual = AK::StringUtils::convert_to_int("0"); + auto actual = AK::StringUtils::convert_to_int("0"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0); - actual = AK::StringUtils::convert_to_int("1"); + actual = AK::StringUtils::convert_to_int("1"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1); - actual = AK::StringUtils::convert_to_int("+1"); + actual = AK::StringUtils::convert_to_int("+1"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1); - actual = AK::StringUtils::convert_to_int("-1"); + actual = AK::StringUtils::convert_to_int("-1"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), -1); - actual = AK::StringUtils::convert_to_int("01"); + actual = AK::StringUtils::convert_to_int("01"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1); - actual = AK::StringUtils::convert_to_int("12345"); + actual = AK::StringUtils::convert_to_int("12345"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 12345); - actual = AK::StringUtils::convert_to_int("-12345"); + actual = AK::StringUtils::convert_to_int("-12345"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), -12345); - actual = AK::StringUtils::convert_to_int(" \t-12345 \n\n"); + actual = AK::StringUtils::convert_to_int(" \t-12345 \n\n"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), -12345); - auto actual_i8 = AK::StringUtils::convert_to_int("-1"); + auto actual_i8 = AK::StringUtils::convert_to_int("-1"sv); EXPECT(actual_i8.has_value()); EXPECT_EQ(actual_i8.value(), -1); EXPECT_EQ(sizeof(actual_i8.value()), (size_t)1); - actual_i8 = AK::StringUtils::convert_to_int("128"); + actual_i8 = AK::StringUtils::convert_to_int("128"sv); EXPECT(!actual_i8.has_value()); - auto actual_i16 = AK::StringUtils::convert_to_int("-1"); + auto actual_i16 = AK::StringUtils::convert_to_int("-1"sv); EXPECT(actual_i16.has_value()); EXPECT_EQ(actual_i16.value(), -1); EXPECT_EQ(sizeof(actual_i16.value()), (size_t)2); - actual_i16 = AK::StringUtils::convert_to_int("32768"); + actual_i16 = AK::StringUtils::convert_to_int("32768"sv); EXPECT(!actual_i16.has_value()); - auto actual_i32 = AK::StringUtils::convert_to_int("-1"); + auto actual_i32 = AK::StringUtils::convert_to_int("-1"sv); EXPECT(actual_i32.has_value()); EXPECT_EQ(actual_i32.value(), -1); EXPECT_EQ(sizeof(actual_i32.value()), (size_t)4); - actual_i32 = AK::StringUtils::convert_to_int("2147483648"); + actual_i32 = AK::StringUtils::convert_to_int("2147483648"sv); EXPECT(!actual_i32.has_value()); - auto actual_i64 = AK::StringUtils::convert_to_int("-1"); + auto actual_i64 = AK::StringUtils::convert_to_int("-1"sv); EXPECT(actual_i64.has_value()); EXPECT_EQ(actual_i64.value(), -1); EXPECT_EQ(sizeof(actual_i64.value()), (size_t)8); - actual_i64 = AK::StringUtils::convert_to_int("9223372036854775808"); + actual_i64 = AK::StringUtils::convert_to_int("9223372036854775808"sv); EXPECT(!actual_i64.has_value()); } @@ -159,70 +159,70 @@ TEST_CASE(convert_to_uint) auto value = AK::StringUtils::convert_to_uint(StringView()); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint(""); + value = AK::StringUtils::convert_to_uint(""sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint("a"); + value = AK::StringUtils::convert_to_uint("a"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint("+"); + value = AK::StringUtils::convert_to_uint("+"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint("-"); + value = AK::StringUtils::convert_to_uint("-"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint("+1"); + value = AK::StringUtils::convert_to_uint("+1"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint("-1"); + value = AK::StringUtils::convert_to_uint("-1"sv); EXPECT(!value.has_value()); - auto actual = AK::StringUtils::convert_to_uint("0"); + auto actual = AK::StringUtils::convert_to_uint("0"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0u); - actual = AK::StringUtils::convert_to_uint("1"); + actual = AK::StringUtils::convert_to_uint("1"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1u); - actual = AK::StringUtils::convert_to_uint("01"); + actual = AK::StringUtils::convert_to_uint("01"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1u); - actual = AK::StringUtils::convert_to_uint("12345"); + actual = AK::StringUtils::convert_to_uint("12345"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 12345u); - actual = AK::StringUtils::convert_to_uint(" \t12345 \n\n"); + actual = AK::StringUtils::convert_to_uint(" \t12345 \n\n"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 12345u); - auto actual_u8 = AK::StringUtils::convert_to_uint("255"); + auto actual_u8 = AK::StringUtils::convert_to_uint("255"sv); EXPECT(actual_u8.has_value()); EXPECT_EQ(actual_u8.value(), 255u); EXPECT_EQ(sizeof(actual_u8.value()), (size_t)1); - actual_u8 = AK::StringUtils::convert_to_uint("256"); + actual_u8 = AK::StringUtils::convert_to_uint("256"sv); EXPECT(!actual_u8.has_value()); - auto actual_u16 = AK::StringUtils::convert_to_uint("65535"); + auto actual_u16 = AK::StringUtils::convert_to_uint("65535"sv); EXPECT(actual_u16.has_value()); EXPECT_EQ(actual_u16.value(), 65535u); EXPECT_EQ(sizeof(actual_u16.value()), (size_t)2); - actual_u16 = AK::StringUtils::convert_to_uint("65536"); + actual_u16 = AK::StringUtils::convert_to_uint("65536"sv); EXPECT(!actual_u16.has_value()); - auto actual_u32 = AK::StringUtils::convert_to_uint("4294967295"); + auto actual_u32 = AK::StringUtils::convert_to_uint("4294967295"sv); EXPECT(actual_u32.has_value()); EXPECT_EQ(actual_u32.value(), 4294967295ul); EXPECT_EQ(sizeof(actual_u32.value()), (size_t)4); - actual_u32 = AK::StringUtils::convert_to_uint("4294967296"); + actual_u32 = AK::StringUtils::convert_to_uint("4294967296"sv); EXPECT(!actual_u32.has_value()); - auto actual_u64 = AK::StringUtils::convert_to_uint("18446744073709551615"); + auto actual_u64 = AK::StringUtils::convert_to_uint("18446744073709551615"sv); EXPECT(actual_u64.has_value()); EXPECT_EQ(actual_u64.value(), 18446744073709551615ull); EXPECT_EQ(sizeof(actual_u64.value()), (size_t)8); - actual_u64 = AK::StringUtils::convert_to_uint("18446744073709551616"); + actual_u64 = AK::StringUtils::convert_to_uint("18446744073709551616"sv); EXPECT(!actual_u64.has_value()); } @@ -231,51 +231,51 @@ TEST_CASE(convert_to_uint_from_octal) auto value = AK::StringUtils::convert_to_uint_from_octal(StringView()); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal(""); + value = AK::StringUtils::convert_to_uint_from_octal(""sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("a"); + value = AK::StringUtils::convert_to_uint_from_octal("a"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("+"); + value = AK::StringUtils::convert_to_uint_from_octal("+"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("-"); + value = AK::StringUtils::convert_to_uint_from_octal("-"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("+1"); + value = AK::StringUtils::convert_to_uint_from_octal("+1"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("-1"); + value = AK::StringUtils::convert_to_uint_from_octal("-1"sv); EXPECT(!value.has_value()); - value = AK::StringUtils::convert_to_uint_from_octal("8"); + value = AK::StringUtils::convert_to_uint_from_octal("8"sv); EXPECT(!value.has_value()); - auto actual = AK::StringUtils::convert_to_uint_from_octal("77777777"); + auto actual = AK::StringUtils::convert_to_uint_from_octal("77777777"sv); EXPECT(!actual.has_value()); - actual = AK::StringUtils::convert_to_uint_from_octal("0"); + actual = AK::StringUtils::convert_to_uint_from_octal("0"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0u); - actual = AK::StringUtils::convert_to_uint_from_octal("1"); + actual = AK::StringUtils::convert_to_uint_from_octal("1"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 1u); - actual = AK::StringUtils::convert_to_uint_from_octal("0755"); + actual = AK::StringUtils::convert_to_uint_from_octal("0755"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0755u); - actual = AK::StringUtils::convert_to_uint_from_octal("755"); + actual = AK::StringUtils::convert_to_uint_from_octal("755"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0755u); - actual = AK::StringUtils::convert_to_uint_from_octal(" \t644 \n\n"); + actual = AK::StringUtils::convert_to_uint_from_octal(" \t644 \n\n"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0644u); - actual = AK::StringUtils::convert_to_uint_from_octal("177777"); + actual = AK::StringUtils::convert_to_uint_from_octal("177777"sv); EXPECT_EQ(actual.has_value(), true); EXPECT_EQ(actual.value(), 0177777u); } @@ -283,85 +283,85 @@ TEST_CASE(convert_to_uint_from_octal) TEST_CASE(ends_with) { String test_string = "ABCDEF"; - EXPECT(AK::StringUtils::ends_with(test_string, "DEF", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDEFG", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::ends_with(test_string, "def", CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::ends_with(test_string, "DEF"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::ends_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDE"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "ABCDEFG"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::ends_with(test_string, "def"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::ends_with(test_string, "def"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(starts_with) { String test_string = "ABCDEF"; - EXPECT(AK::StringUtils::starts_with(test_string, "ABC", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::starts_with(test_string, "BCDEF", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::starts_with(test_string, "ABCDEFG", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::starts_with(test_string, "abc", CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::starts_with(test_string, "ABC"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::starts_with(test_string, "ABCDEF"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::starts_with(test_string, "BCDEF"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::starts_with(test_string, "ABCDEFG"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::starts_with(test_string, "abc"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::starts_with(test_string, "abc"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(contains) { String test_string = "ABCDEFABCXYZ"; - EXPECT(AK::StringUtils::contains(test_string, "ABC", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::contains(test_string, "ABC", CaseSensitivity::CaseInsensitive)); - EXPECT(AK::StringUtils::contains(test_string, "AbC", CaseSensitivity::CaseInsensitive)); - EXPECT(AK::StringUtils::contains(test_string, "BCX", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::contains(test_string, "BCX", CaseSensitivity::CaseInsensitive)); - EXPECT(AK::StringUtils::contains(test_string, "BcX", CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::contains(test_string, "xyz", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::contains(test_string, "xyz", CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::contains(test_string, "EFG", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::contains(test_string, "EfG", CaseSensitivity::CaseInsensitive)); - EXPECT(AK::StringUtils::contains(test_string, "", CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::contains(test_string, "", CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::contains("", test_string, CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::contains("", test_string, CaseSensitivity::CaseInsensitive)); - EXPECT(!AK::StringUtils::contains(test_string, "L", CaseSensitivity::CaseSensitive)); - EXPECT(!AK::StringUtils::contains(test_string, "L", CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::contains(test_string, "ABC"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(test_string, "AbC"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(test_string, "BCX"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::contains(test_string, "BCX"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(test_string, "BcX"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::contains(test_string, "xyz"sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::contains(test_string, "xyz"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::contains(test_string, "EFG"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::contains(test_string, "EfG"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(test_string, ""sv, CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::contains(test_string, ""sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::contains(""sv, test_string, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::contains(""sv, test_string, CaseSensitivity::CaseInsensitive)); + EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseSensitive)); + EXPECT(!AK::StringUtils::contains(test_string, "L"sv, CaseSensitivity::CaseInsensitive)); String command_palette_bug_string = "Go Go Back"; - EXPECT(AK::StringUtils::contains(command_palette_bug_string, "Go Back", AK::CaseSensitivity::CaseSensitive)); - EXPECT(AK::StringUtils::contains(command_palette_bug_string, "gO bAcK", AK::CaseSensitivity::CaseInsensitive)); + EXPECT(AK::StringUtils::contains(command_palette_bug_string, "Go Back"sv, AK::CaseSensitivity::CaseSensitive)); + EXPECT(AK::StringUtils::contains(command_palette_bug_string, "gO bAcK"sv, AK::CaseSensitivity::CaseInsensitive)); } TEST_CASE(is_whitespace) { - EXPECT(AK::StringUtils::is_whitespace("")); - EXPECT(AK::StringUtils::is_whitespace(" ")); - EXPECT(AK::StringUtils::is_whitespace(" \t")); - EXPECT(AK::StringUtils::is_whitespace(" \t\n")); - EXPECT(AK::StringUtils::is_whitespace(" \t\n\r\v")); - EXPECT(!AK::StringUtils::is_whitespace(" a ")); - EXPECT(!AK::StringUtils::is_whitespace("a\t")); + EXPECT(AK::StringUtils::is_whitespace(""sv)); + EXPECT(AK::StringUtils::is_whitespace(" "sv)); + EXPECT(AK::StringUtils::is_whitespace(" \t"sv)); + EXPECT(AK::StringUtils::is_whitespace(" \t\n"sv)); + EXPECT(AK::StringUtils::is_whitespace(" \t\n\r\v"sv)); + EXPECT(!AK::StringUtils::is_whitespace(" a "sv)); + EXPECT(!AK::StringUtils::is_whitespace("a\t"sv)); } TEST_CASE(find) { String test_string = "1234567"; - EXPECT_EQ(AK::StringUtils::find(test_string, "1").value_or(1), 0u); - EXPECT_EQ(AK::StringUtils::find(test_string, "2").value_or(2), 1u); - EXPECT_EQ(AK::StringUtils::find(test_string, "3").value_or(3), 2u); - EXPECT_EQ(AK::StringUtils::find(test_string, "4").value_or(4), 3u); - EXPECT_EQ(AK::StringUtils::find(test_string, "5").value_or(5), 4u); - EXPECT_EQ(AK::StringUtils::find(test_string, "34").value_or(3), 2u); - EXPECT_EQ(AK::StringUtils::find(test_string, "78").has_value(), false); + EXPECT_EQ(AK::StringUtils::find(test_string, "1"sv).value_or(1), 0u); + EXPECT_EQ(AK::StringUtils::find(test_string, "2"sv).value_or(2), 1u); + EXPECT_EQ(AK::StringUtils::find(test_string, "3"sv).value_or(3), 2u); + EXPECT_EQ(AK::StringUtils::find(test_string, "4"sv).value_or(4), 3u); + EXPECT_EQ(AK::StringUtils::find(test_string, "5"sv).value_or(5), 4u); + EXPECT_EQ(AK::StringUtils::find(test_string, "34"sv).value_or(3), 2u); + EXPECT_EQ(AK::StringUtils::find(test_string, "78"sv).has_value(), false); } TEST_CASE(to_snakecase) { - EXPECT_EQ(AK::StringUtils::to_snakecase("foobar"), "foobar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("Foobar"), "foobar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("FOOBAR"), "foobar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("fooBar"), "foo_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("FooBar"), "foo_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("fooBAR"), "foo_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("FOOBar"), "foo_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("foo_bar"), "foo_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("FBar"), "f_bar"); - EXPECT_EQ(AK::StringUtils::to_snakecase("FooB"), "foo_b"); + EXPECT_EQ(AK::StringUtils::to_snakecase("foobar"sv), "foobar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("Foobar"sv), "foobar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("FOOBAR"sv), "foobar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("fooBar"sv), "foo_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("FooBar"sv), "foo_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("fooBAR"sv), "foo_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("FOOBar"sv), "foo_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("foo_bar"sv), "foo_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("FBar"sv), "f_bar"); + EXPECT_EQ(AK::StringUtils::to_snakecase("FooB"sv), "foo_b"); } TEST_CASE(to_titlecase) diff --git a/Tests/AK/TestStringView.cpp b/Tests/AK/TestStringView.cpp index 2de877adeb8..91b124aec80 100644 --- a/Tests/AK/TestStringView.cpp +++ b/Tests/AK/TestStringView.cpp @@ -55,25 +55,25 @@ TEST_CASE(starts_with) StringView test_string_view = test_string.view(); EXPECT(test_string_view.starts_with('A')); EXPECT(!test_string_view.starts_with('B')); - EXPECT(test_string_view.starts_with("AB")); - EXPECT(test_string_view.starts_with("ABCDEF")); - EXPECT(!test_string_view.starts_with("DEF")); - EXPECT(test_string_view.starts_with("abc", CaseSensitivity::CaseInsensitive)); - EXPECT(!test_string_view.starts_with("abc", CaseSensitivity::CaseSensitive)); + EXPECT(test_string_view.starts_with("AB"sv)); + EXPECT(test_string_view.starts_with("ABCDEF"sv)); + EXPECT(!test_string_view.starts_with("DEF"sv)); + EXPECT(test_string_view.starts_with("abc"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string_view.starts_with("abc"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(ends_with) { String test_string = "ABCDEF"; StringView test_string_view = test_string.view(); - EXPECT(test_string_view.ends_with("DEF")); + EXPECT(test_string_view.ends_with("DEF"sv)); EXPECT(test_string_view.ends_with('F')); EXPECT(!test_string_view.ends_with('E')); - EXPECT(test_string_view.ends_with("ABCDEF")); - EXPECT(!test_string_view.ends_with("ABCDE")); - EXPECT(!test_string_view.ends_with("ABCDEFG")); - EXPECT(test_string_view.ends_with("def", CaseSensitivity::CaseInsensitive)); - EXPECT(!test_string_view.ends_with("def", CaseSensitivity::CaseSensitive)); + EXPECT(test_string_view.ends_with("ABCDEF"sv)); + EXPECT(!test_string_view.ends_with("ABCDE"sv)); + EXPECT(!test_string_view.ends_with("ABCDEFG"sv)); + EXPECT(test_string_view.ends_with("def"sv, CaseSensitivity::CaseInsensitive)); + EXPECT(!test_string_view.ends_with("def"sv, CaseSensitivity::CaseSensitive)); } TEST_CASE(lines) @@ -127,42 +127,42 @@ TEST_CASE(find_last) TEST_CASE(find_any_of) { auto test_string_view = "aabbcc_xy_ccbbaa"sv; - EXPECT_EQ(test_string_view.find_any_of("bc", StringView::SearchDirection::Forward), 2U); - EXPECT_EQ(test_string_view.find_any_of("yx", StringView::SearchDirection::Forward), 7U); - EXPECT_EQ(test_string_view.find_any_of("defg", StringView::SearchDirection::Forward).has_value(), false); - EXPECT_EQ(test_string_view.find_any_of("bc", StringView::SearchDirection::Backward), 13U); - EXPECT_EQ(test_string_view.find_any_of("yx", StringView::SearchDirection::Backward), 8U); - EXPECT_EQ(test_string_view.find_any_of("fghi", StringView::SearchDirection::Backward).has_value(), false); + EXPECT_EQ(test_string_view.find_any_of("bc"sv, StringView::SearchDirection::Forward), 2U); + EXPECT_EQ(test_string_view.find_any_of("yx"sv, StringView::SearchDirection::Forward), 7U); + EXPECT_EQ(test_string_view.find_any_of("defg"sv, StringView::SearchDirection::Forward).has_value(), false); + EXPECT_EQ(test_string_view.find_any_of("bc"sv, StringView::SearchDirection::Backward), 13U); + EXPECT_EQ(test_string_view.find_any_of("yx"sv, StringView::SearchDirection::Backward), 8U); + EXPECT_EQ(test_string_view.find_any_of("fghi"sv, StringView::SearchDirection::Backward).has_value(), false); test_string_view = "/"sv; - EXPECT_EQ(test_string_view.find_any_of("/", StringView::SearchDirection::Forward), 0U); - EXPECT_EQ(test_string_view.find_any_of("/", StringView::SearchDirection::Backward), 0U); + EXPECT_EQ(test_string_view.find_any_of("/"sv, StringView::SearchDirection::Forward), 0U); + EXPECT_EQ(test_string_view.find_any_of("/"sv, StringView::SearchDirection::Backward), 0U); } TEST_CASE(split_view) { - StringView test_string_view = "axxbxcxd"; - EXPECT_EQ(test_string_view.split_view('x'), Vector({ "a", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view('x', true), Vector({ "a", "", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view("x"), Vector({ "a", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view("x", true), Vector({ "a", "", "b", "c", "d" })); + StringView test_string_view = "axxbxcxd"sv; + EXPECT_EQ(test_string_view.split_view('x'), Vector({ "a"sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view('x', true), Vector({ "a"sv, ""sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view("x"sv), Vector({ "a"sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view("x"sv, true), Vector({ "a"sv, ""sv, "b"sv, "c"sv, "d"sv })); - test_string_view = "axxbx"; - EXPECT_EQ(test_string_view.split_view('x'), Vector({ "a", "b" })); - EXPECT_EQ(test_string_view.split_view('x', true), Vector({ "a", "", "b", "" })); - EXPECT_EQ(test_string_view.split_view("x"), Vector({ "a", "b" })); - EXPECT_EQ(test_string_view.split_view("x", true), Vector({ "a", "", "b", "" })); + test_string_view = "axxbx"sv; + EXPECT_EQ(test_string_view.split_view('x'), Vector({ "a"sv, "b"sv })); + EXPECT_EQ(test_string_view.split_view('x', true), Vector({ "a"sv, ""sv, "b"sv, ""sv })); + EXPECT_EQ(test_string_view.split_view("x"sv), Vector({ "a"sv, "b"sv })); + EXPECT_EQ(test_string_view.split_view("x"sv, true), Vector({ "a"sv, ""sv, "b"sv, ""sv })); - test_string_view = "axxbcxxdxx"; - EXPECT_EQ(test_string_view.split_view("xx"), Vector({ "a", "bc", "d" })); - EXPECT_EQ(test_string_view.split_view("xx", true), Vector({ "a", "bc", "d", "" })); + test_string_view = "axxbcxxdxx"sv; + EXPECT_EQ(test_string_view.split_view("xx"sv), Vector({ "a"sv, "bc"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view("xx"sv, true), Vector({ "a"sv, "bc"sv, "d"sv, ""sv })); - test_string_view = "ax_b_cxd"; + test_string_view = "ax_b_cxd"sv; Function predicate = [](char ch) { return ch == 'x' || ch == '_'; }; - EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view_if(predicate, true), Vector({ "a", "", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a", "b", "c", "d" })); - EXPECT_EQ(test_string_view.split_view_if(predicate, true), Vector({ "a", "", "b", "c", "d" })); + EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a"sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view_if(predicate, true), Vector({ "a"sv, ""sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view_if(predicate), Vector({ "a"sv, "b"sv, "c"sv, "d"sv })); + EXPECT_EQ(test_string_view.split_view_if(predicate, true), Vector({ "a"sv, ""sv, "b"sv, "c"sv, "d"sv })); } TEST_CASE(constexpr_stuff) diff --git a/Tests/AK/TestTrie.cpp b/Tests/AK/TestTrie.cpp index 7334f3a6407..6091ea8b77e 100644 --- a/Tests/AK/TestTrie.cpp +++ b/Tests/AK/TestTrie.cpp @@ -12,7 +12,7 @@ TEST_CASE(normal_behavior) { Trie dictionary('/', ""); - constexpr StringView data[] { "test", "example", "foo", "foobar" }; + constexpr StringView data[] { "test"sv, "example"sv, "foo"sv, "foobar"sv }; constexpr size_t total_chars = 18; // root (1), 'test' (4), 'example' (7), 'foo' (3), 'foobar' (3, "foo" already stored). for (auto& view : data) { auto it = view.begin(); @@ -33,7 +33,7 @@ TEST_CASE(normal_behavior) EXPECT_EQ(view, node.metadata_value()); } - constexpr StringView test_data_with_prefix_in_dict[] { "testx", "exampley", "fooa", "foobarb", "fox", "text" }; + constexpr StringView test_data_with_prefix_in_dict[] { "testx"sv, "exampley"sv, "fooa"sv, "foobarb"sv, "fox"sv, "text"sv }; for (auto& view : test_data_with_prefix_in_dict) { auto it = view.begin(); auto& node = dictionary.traverse_until_last_accessible_node(it, view.end()); diff --git a/Tests/AK/TestURL.cpp b/Tests/AK/TestURL.cpp index 30128963117..26eed0a2efd 100644 --- a/Tests/AK/TestURL.cpp +++ b/Tests/AK/TestURL.cpp @@ -316,7 +316,7 @@ TEST_CASE(port_overflow) TEST_CASE(equality) { - EXPECT(URL("http://serenityos.org").equals("http://serenityos.org#test", URL::ExcludeFragment::Yes)); + EXPECT(URL("http://serenityos.org").equals("http://serenityos.org#test"sv, URL::ExcludeFragment::Yes)); EXPECT_EQ(URL("http://example.com/index.html"), URL("http://ex%61mple.com/index.html")); EXPECT_EQ(URL("file:///my/file"), URL("file://localhost/my/file")); EXPECT_NE(URL("http://serenityos.org/index.html"), URL("http://serenityos.org/test.html")); diff --git a/Tests/AK/TestVector.cpp b/Tests/AK/TestVector.cpp index 3216c24a3c2..ed3ac75e2a6 100644 --- a/Tests/AK/TestVector.cpp +++ b/Tests/AK/TestVector.cpp @@ -65,8 +65,8 @@ TEST_CASE(strings_insert_ordered) strings.append("def"); strings.append("ghi"); - strings.insert_before_matching("f-g", [](auto& entry) { - return "f-g" < entry; + strings.insert_before_matching("f-g"sv, [](auto& entry) { + return "f-g"sv < entry; }); EXPECT_EQ(strings[0], "abc"); diff --git a/Tests/Kernel/fuzz-syscalls.cpp b/Tests/Kernel/fuzz-syscalls.cpp index 8ec795a66b8..63be4a433f9 100644 --- a/Tests/Kernel/fuzz-syscalls.cpp +++ b/Tests/Kernel/fuzz-syscalls.cpp @@ -97,7 +97,7 @@ static void do_weird_call(size_t attempt, int syscall_fn, size_t arg1, size_t ar attempt, Syscall::to_string((Syscall::Function)syscall_fn), arg1, arg2, arg3, fake_params); for (size_t i = 0; i < fake_params_count; ++i) { if (i != 0) - builder.append(", "); + builder.append(", "sv); builder.appendff("{:p}", fake_params[i]); } builder.append("]"); diff --git a/Tests/LibCompress/TestBrotli.cpp b/Tests/LibCompress/TestBrotli.cpp index 447df841c80..bff42326f50 100644 --- a/Tests/LibCompress/TestBrotli.cpp +++ b/Tests/LibCompress/TestBrotli.cpp @@ -32,47 +32,47 @@ static void run_test(StringView const file_name) TEST_CASE(brotli_decompress_uncompressed) { - run_test("wellhello.txt"); + run_test("wellhello.txt"sv); } TEST_CASE(brotli_decompress_simple) { - run_test("hello.txt"); + run_test("hello.txt"sv); } TEST_CASE(brotli_decompress_simple2) { - run_test("wellhello2.txt"); + run_test("wellhello2.txt"sv); } TEST_CASE(brotli_decompress_lorem) { - run_test("lorem.txt"); + run_test("lorem.txt"sv); } TEST_CASE(brotli_decompress_lorem2) { - run_test("lorem2.txt"); + run_test("lorem2.txt"sv); } TEST_CASE(brotli_decompress_transform) { - run_test("transform.txt"); + run_test("transform.txt"sv); } TEST_CASE(brotli_decompress_serenityos_html) { - run_test("serenityos.html"); + run_test("serenityos.html"sv); } TEST_CASE(brotli_decompress_happy3rd_html) { - run_test("happy3rd.html"); + run_test("happy3rd.html"sv); } TEST_CASE(brotli_decompress_katica_regular_10_font) { - run_test("KaticaRegular10.font"); + run_test("KaticaRegular10.font"sv); } TEST_CASE(brotli_decompress_zero_one_bin) diff --git a/Tests/LibCore/TestLibCoreFilePermissionsMask.cpp b/Tests/LibCore/TestLibCoreFilePermissionsMask.cpp index 60cedb6d517..96bc6064e0f 100644 --- a/Tests/LibCore/TestLibCoreFilePermissionsMask.cpp +++ b/Tests/LibCore/TestLibCoreFilePermissionsMask.cpp @@ -74,19 +74,19 @@ TEST_CASE(file_permission_mask_from_symbolic_notation) mask = Core::FilePermissionsMask::from_symbolic_notation("z+rw"sv); EXPECT(mask.is_error()); - EXPECT(mask.error().string_literal().starts_with("invalid class")); + EXPECT(mask.error().string_literal().starts_with("invalid class"sv)); mask = Core::FilePermissionsMask::from_symbolic_notation("u*rw"sv); EXPECT(mask.is_error()); - EXPECT(mask.error().string_literal().starts_with("invalid operation")); + EXPECT(mask.error().string_literal().starts_with("invalid operation"sv)); mask = Core::FilePermissionsMask::from_symbolic_notation("u+rz"sv); EXPECT(mask.is_error()); - EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission")); + EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"sv)); mask = Core::FilePermissionsMask::from_symbolic_notation("u+rw;g+rw"sv); EXPECT(mask.is_error()); - EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission")); + EXPECT(mask.error().string_literal().starts_with("invalid symbolic permission"sv)); } TEST_CASE(file_permission_mask_parse) @@ -100,9 +100,9 @@ TEST_CASE(file_permission_mask_parse) EXPECT_EQ(numeric_mask.value().clear_mask(), symbolic_mask.value().clear_mask()); EXPECT_EQ(numeric_mask.value().write_mask(), symbolic_mask.value().write_mask()); - auto mask = Core::FilePermissionsMask::parse("888"); + auto mask = Core::FilePermissionsMask::parse("888"sv); EXPECT(mask.is_error()); - mask = Core::FilePermissionsMask::parse("z+rw"); + mask = Core::FilePermissionsMask::parse("z+rw"sv); EXPECT(mask.is_error()); } diff --git a/Tests/LibCore/TestLibCoreIODevice.cpp b/Tests/LibCore/TestLibCoreIODevice.cpp index 8bb74f26fd7..808339fe7a5 100644 --- a/Tests/LibCore/TestLibCoreIODevice.cpp +++ b/Tests/LibCore/TestLibCoreIODevice.cpp @@ -30,7 +30,7 @@ TEST_CASE(file_readline) auto outputfile = outfile_or_error.release_value(); while (file->can_read_line()) { outputfile->write(file->read_line()); - outputfile->write("\n"); + outputfile->write("\n"sv); } file->close(); outputfile->close(); @@ -84,7 +84,7 @@ TEST_CASE(file_lines_range) auto outputfile = outfile_or_error.release_value(); for (auto line : file->lines()) { outputfile->write(line); - outputfile->write("\n"); + outputfile->write("\n"sv); } file->close(); outputfile->close(); diff --git a/Tests/LibCore/TestLibCoreStream.cpp b/Tests/LibCore/TestLibCoreStream.cpp index fcb326cc149..cb6b4055926 100644 --- a/Tests/LibCore/TestLibCoreStream.cpp +++ b/Tests/LibCore/TestLibCoreStream.cpp @@ -20,7 +20,7 @@ TEST_CASE(file_open) { - auto maybe_file = Core::Stream::File::open("/tmp/file-open-test.txt", Core::Stream::OpenMode::Write); + auto maybe_file = Core::Stream::File::open("/tmp/file-open-test.txt"sv, Core::Stream::OpenMode::Write); if (maybe_file.is_error()) { warnln("Failed to open the file: {}", strerror(maybe_file.error().code())); VERIFY_NOT_REACHED(); @@ -40,7 +40,7 @@ TEST_CASE(file_open) TEST_CASE(file_write_bytes) { - auto maybe_file = Core::Stream::File::open("/tmp/file-write-bytes-test.txt", Core::Stream::OpenMode::Write); + auto maybe_file = Core::Stream::File::open("/tmp/file-write-bytes-test.txt"sv, Core::Stream::OpenMode::Write); auto file = maybe_file.release_value(); constexpr auto some_words = "These are some words"sv; @@ -53,7 +53,7 @@ constexpr auto expected_buffer_contents = "<small>(Please consider transla TEST_CASE(file_read_bytes) { - auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read); + auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read); EXPECT(!maybe_file.is_error()); auto file = maybe_file.release_value(); @@ -75,7 +75,7 @@ constexpr auto expected_seek_contents3 = "levels of advanc"sv; TEST_CASE(file_seeking_around) { - auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read); + auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read); EXPECT(!maybe_file.is_error()); auto file = maybe_file.release_value(); @@ -137,7 +137,7 @@ TEST_CASE(file_adopt_invalid_fd) TEST_CASE(file_truncate) { - auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt", Core::Stream::OpenMode::Write); + auto maybe_file = Core::Stream::File::open("/tmp/file-truncate-test.txt"sv, Core::Stream::OpenMode::Write); auto file = maybe_file.release_value(); EXPECT(!file->truncate(999).is_error()); @@ -417,7 +417,7 @@ TEST_CASE(local_socket_write) TEST_CASE(buffered_long_file_read) { - auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt", Core::Stream::OpenMode::Read); + auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/long_lines.txt"sv, Core::Stream::OpenMode::Read); EXPECT(!maybe_file.is_error()); auto maybe_buffered_file = Core::Stream::BufferedFile::create(maybe_file.release_value()); EXPECT(!maybe_buffered_file.is_error()); @@ -439,7 +439,7 @@ TEST_CASE(buffered_long_file_read) TEST_CASE(buffered_small_file_read) { - auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/small.txt", Core::Stream::OpenMode::Read); + auto maybe_file = Core::Stream::File::open("/usr/Tests/LibCore/small.txt"sv, Core::Stream::OpenMode::Read); EXPECT(!maybe_file.is_error()); auto maybe_buffered_file = Core::Stream::BufferedFile::create(maybe_file.release_value()); EXPECT(!maybe_buffered_file.is_error()); diff --git a/Tests/LibCpp/test-cpp-parser.cpp b/Tests/LibCpp/test-cpp-parser.cpp index 18eb0dcff14..bf18d500f23 100644 --- a/Tests/LibCpp/test-cpp-parser.cpp +++ b/Tests/LibCpp/test-cpp-parser.cpp @@ -31,7 +31,7 @@ TEST_CASE(test_regression) auto file_path = directory_iterator.next_full_path(); auto path = LexicalPath { file_path }; - if (!path.has_extension(".cpp")) + if (!path.has_extension(".cpp"sv)) continue; outln("Checking {}...", path.basename()); diff --git a/Tests/LibCpp/test-cpp-preprocessor.cpp b/Tests/LibCpp/test-cpp-preprocessor.cpp index 75c7724a528..9cd4a924442 100644 --- a/Tests/LibCpp/test-cpp-preprocessor.cpp +++ b/Tests/LibCpp/test-cpp-preprocessor.cpp @@ -30,7 +30,7 @@ TEST_CASE(test_regression) auto file_path = directory_iterator.next_full_path(); auto path = LexicalPath { file_path }; - if (!path.has_extension(".cpp")) + if (!path.has_extension(".cpp"sv)) continue; outln("Checking {}...", path.basename()); diff --git a/Tests/LibCrypto/TestBigInteger.cpp b/Tests/LibCrypto/TestBigInteger.cpp index 94beca95539..b13e8aafedd 100644 --- a/Tests/LibCrypto/TestBigInteger.cpp +++ b/Tests/LibCrypto/TestBigInteger.cpp @@ -234,7 +234,7 @@ TEST_CASE(test_unsigned_bigint_division_combined_test) TEST_CASE(test_unsigned_bigint_base10_from_string) { - auto result = Crypto::UnsignedBigInteger::from_base(10, "57195071295721390579057195715793"); + auto result = Crypto::UnsignedBigInteger::from_base(10, "57195071295721390579057195715793"sv); Vector expected_result { 3806301393, 954919431, 3879607298, 721 }; EXPECT_EQ(result.words(), expected_result); } @@ -414,7 +414,7 @@ TEST_CASE(test_bigint_import_big_endian_encode_decode_roundtrip) TEST_CASE(test_bigint_big_endian_import) { - auto number = Crypto::UnsignedBigInteger::import_data("hello"); + auto number = Crypto::UnsignedBigInteger::import_data("hello"sv); EXPECT_EQ(number, "448378203247"_bigint); } diff --git a/Tests/LibCrypto/TestHMAC.cpp b/Tests/LibCrypto/TestHMAC.cpp index c07d371c8b5..ec655538671 100644 --- a/Tests/LibCrypto/TestHMAC.cpp +++ b/Tests/LibCrypto/TestHMAC.cpp @@ -13,34 +13,34 @@ TEST_CASE(test_hmac_md5_name) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); - EXPECT_EQ(hmac.class_name(), "HMAC-MD5"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); + EXPECT_EQ(hmac.class_name(), "HMAC-MD5"sv); } TEST_CASE(test_hmac_md5_process) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); u8 result[] { 0x3b, 0x5b, 0xde, 0x30, 0x3a, 0x54, 0x7b, 0xbb, 0x09, 0xfe, 0x78, 0x89, 0xbc, 0x9f, 0x22, 0xa3 }; - auto mac = hmac.process("Some bogus data"); + auto mac = hmac.process("Some bogus data"sv); EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_md5_process_reuse) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); - auto mac_0 = hmac.process("Some bogus data"); - auto mac_1 = hmac.process("Some bogus data"); + auto mac_0 = hmac.process("Some bogus data"sv); + auto mac_1 = hmac.process("Some bogus data"sv); EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha1_name) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); - EXPECT_EQ(hmac.class_name(), "HMAC-SHA1"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); + EXPECT_EQ(hmac.class_name(), "HMAC-SHA1"sv); } TEST_CASE(test_hmac_sha1_process) @@ -76,72 +76,72 @@ TEST_CASE(test_hmac_sha1_process_reuse) TEST_CASE(test_hmac_sha256_name) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); - EXPECT_EQ(hmac.class_name(), "HMAC-SHA256"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); + EXPECT_EQ(hmac.class_name(), "HMAC-SHA256"sv); } TEST_CASE(test_hmac_sha256_process) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); u8 result[] { 0x1a, 0xf2, 0x20, 0x62, 0xde, 0x3b, 0x84, 0x65, 0xc1, 0x25, 0x23, 0x99, 0x76, 0x15, 0x1b, 0xec, 0x15, 0x21, 0x82, 0x1f, 0x23, 0xca, 0x11, 0x66, 0xdd, 0x8c, 0x6e, 0xf1, 0x81, 0x3b, 0x7f, 0x1b }; - auto mac = hmac.process("Some bogus data"); + auto mac = hmac.process("Some bogus data"sv); EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha256_reuse) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); - auto mac_0 = hmac.process("Some bogus data"); - auto mac_1 = hmac.process("Some bogus data"); + auto mac_0 = hmac.process("Some bogus data"sv); + auto mac_1 = hmac.process("Some bogus data"sv); EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha256_data_is_same_size_as_block) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); u8 result[] = { 0x1d, 0x90, 0xce, 0x68, 0x45, 0x0b, 0xba, 0xd6, 0xbe, 0x1c, 0xb2, 0x3a, 0xea, 0x7f, 0xac, 0x4b, 0x68, 0x08, 0xa4, 0x77, 0x81, 0x2a, 0xad, 0x5d, 0x05, 0xe2, 0x15, 0xe8, 0xf4, 0xcb, 0x06, 0xaf }; - auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv); EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha256_data_is_bigger_size_as_block) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); u8 result[] = { 0x9b, 0xa3, 0x9e, 0xf3, 0xb4, 0x30, 0x5f, 0x6f, 0x67, 0xd0, 0xa8, 0xb0, 0xf0, 0xcb, 0x12, 0xf5, 0x85, 0xe2, 0x19, 0xba, 0x0c, 0x8b, 0xe5, 0x43, 0xf0, 0x93, 0x39, 0xa8, 0xa3, 0x07, 0xf1, 0x95 }; - auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + auto mac = hmac.process("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv); EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha512_name) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); EXPECT_EQ(hmac.class_name(), "HMAC-SHA512"); } TEST_CASE(test_hmac_sha512_process) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); u8 result[] { 0xeb, 0xa8, 0x34, 0x11, 0xfd, 0x5b, 0x46, 0x5b, 0xef, 0xbb, 0x67, 0x5e, 0x7d, 0xc2, 0x7c, 0x2c, 0x6b, 0xe1, 0xcf, 0xe6, 0xc7, 0xe4, 0x7d, 0xeb, 0xca, 0x97, 0xb7, 0x4c, 0xd3, 0x4d, 0x6f, 0x08, 0x9f, 0x0d, 0x3a, 0xf1, 0xcb, 0x00, 0x79, 0x78, 0x2f, 0x05, 0x8e, 0xeb, 0x94, 0x48, 0x0d, 0x50, 0x64, 0x3b, 0xca, 0x70, 0xe2, 0x69, 0x38, 0x4f, 0xe4, 0xb0, 0x49, 0x0f, 0xc5, 0x4c, 0x7a, 0xa7 }; - auto mac = hmac.process("Some bogus data"); + auto mac = hmac.process("Some bogus data"sv); EXPECT(memcmp(result, mac.data, hmac.digest_size()) == 0); } TEST_CASE(test_hmac_sha512_reuse) { - Crypto::Authentication::HMAC hmac("Well Hello Friends"); + Crypto::Authentication::HMAC hmac("Well Hello Friends"sv); - auto mac_0 = hmac.process("Some bogus data"); - auto mac_1 = hmac.process("Some bogus data"); + auto mac_0 = hmac.process("Some bogus data"sv); + auto mac_1 = hmac.process("Some bogus data"sv); EXPECT(memcmp(mac_0.data, mac_1.data, hmac.digest_size()) == 0); } diff --git a/Tests/LibCrypto/TestHash.cpp b/Tests/LibCrypto/TestHash.cpp index 29fd33f88c8..d59ba7defd0 100644 --- a/Tests/LibCrypto/TestHash.cpp +++ b/Tests/LibCrypto/TestHash.cpp @@ -23,7 +23,7 @@ TEST_CASE(test_MD5_hash_string) u8 result[] { 0xaf, 0x04, 0x3a, 0x08, 0x94, 0x38, 0x6e, 0x7f, 0xbf, 0x73, 0xe4, 0xaa, 0xf0, 0x8e, 0xee, 0x4c }; - auto digest = Crypto::Hash::MD5::hash("Well hello friends"); + auto digest = Crypto::Hash::MD5::hash("Well hello friends"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); } @@ -32,7 +32,7 @@ TEST_CASE(test_MD5_hash_empty_string) u8 result[] { 0xd4, 0x1d, 0x8c, 0xd9, 0x8f, 0x00, 0xb2, 0x04, 0xe9, 0x80, 0x09, 0x98, 0xec, 0xf8, 0x42, 0x7e }; - auto digest = Crypto::Hash::MD5::hash(""); + auto digest = Crypto::Hash::MD5::hash(""sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); } @@ -41,7 +41,7 @@ TEST_CASE(test_MD5_hash_single_character) u8 result[] { 0x0c, 0xc1, 0x75, 0xb9, 0xc0, 0xf1, 0xb6, 0xa8, 0x31, 0xc3, 0x99, 0xe2, 0x69, 0x77, 0x26, 0x61 }; - auto digest = Crypto::Hash::MD5::hash("a"); + auto digest = Crypto::Hash::MD5::hash("a"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); } @@ -50,7 +50,7 @@ TEST_CASE(test_MD5_hash_alphabet) u8 result[] { 0xc3, 0xfc, 0xd3, 0xd7, 0x61, 0x92, 0xe4, 0x00, 0x7d, 0xfb, 0x49, 0x6c, 0xca, 0x67, 0xe1, 0x3b }; - auto digest = Crypto::Hash::MD5::hash("abcdefghijklmnopqrstuvwxyz"); + auto digest = Crypto::Hash::MD5::hash("abcdefghijklmnopqrstuvwxyz"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); } @@ -59,7 +59,7 @@ TEST_CASE(test_MD5_hash_long_sequence) u8 result[] { 0x57, 0xed, 0xf4, 0xa2, 0x2b, 0xe3, 0xc9, 0x55, 0xac, 0x49, 0xda, 0x2e, 0x21, 0x07, 0xb6, 0x7a }; - auto digest = Crypto::Hash::MD5::hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); + auto digest = Crypto::Hash::MD5::hash("12345678901234567890123456789012345678901234567890123456789012345678901234567890"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); } @@ -70,9 +70,9 @@ TEST_CASE(test_MD5_consecutive_multiple_updates) }; Crypto::Hash::MD5 md5; - md5.update("Well"); - md5.update(" hello "); - md5.update("friends"); + md5.update("Well"sv); + md5.update(" hello "sv); + md5.update("friends"sv); auto digest = md5.digest(); EXPECT(memcmp(result, digest.data, Crypto::Hash::MD5::digest_size()) == 0); @@ -82,14 +82,14 @@ TEST_CASE(test_MD5_consecutive_updates_reuse) { Crypto::Hash::MD5 md5; - md5.update("Well"); - md5.update(" hello "); - md5.update("friends"); + md5.update("Well"sv); + md5.update(" hello "sv); + md5.update("friends"sv); auto digest0 = md5.digest(); - md5.update("Well"); - md5.update(" hello "); - md5.update("friends"); + md5.update("Well"sv); + md5.update(" hello "sv); + md5.update("friends"sv); auto digest1 = md5.digest(); EXPECT(memcmp(digest0.data, digest1.data, Crypto::Hash::MD5::digest_size()) == 0); @@ -98,7 +98,7 @@ TEST_CASE(test_MD5_consecutive_updates_reuse) TEST_CASE(test_SHA1_name) { Crypto::Hash::SHA1 sha; - EXPECT(sha.class_name() == "SHA1"); + EXPECT(sha.class_name() == "SHA1"sv); } TEST_CASE(test_SHA1_hash_empty_string) @@ -106,7 +106,7 @@ TEST_CASE(test_SHA1_hash_empty_string) u8 result[] { 0xda, 0x39, 0xa3, 0xee, 0x5e, 0x6b, 0x4b, 0x0d, 0x32, 0x55, 0xbf, 0xef, 0x95, 0x60, 0x18, 0x90, 0xaf, 0xd8, 0x07, 0x09 }; - auto digest = Crypto::Hash::SHA1::hash(""); + auto digest = Crypto::Hash::SHA1::hash(""sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0); } @@ -115,7 +115,7 @@ TEST_CASE(test_SHA1_hash_long_string) u8 result[] { 0x12, 0x15, 0x1f, 0xb1, 0x04, 0x44, 0x93, 0xcc, 0xed, 0x54, 0xa6, 0xb8, 0x7e, 0x93, 0x37, 0x7b, 0xb2, 0x13, 0x39, 0xdb }; - auto digest = Crypto::Hash::SHA1::hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); + auto digest = Crypto::Hash::SHA1::hash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0); } @@ -125,19 +125,19 @@ TEST_CASE(test_SHA1_hash_successive_updates) 0xd6, 0x6e, 0xce, 0xd1, 0xf4, 0x08, 0xc6, 0xd8, 0x35, 0xab, 0xf0, 0xc9, 0x05, 0x26, 0xa4, 0xb2, 0xb8, 0xa3, 0x7c, 0xd3 }; auto hasher = Crypto::Hash::SHA1 {}; - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaaaaaaaa"); - hasher.update("aaaaaaaaa"); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaaaaaaaa"sv); + hasher.update("aaaaaaaaa"sv); auto digest = hasher.digest(); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA1::digest_size()) == 0); } @@ -145,7 +145,7 @@ TEST_CASE(test_SHA1_hash_successive_updates) TEST_CASE(test_SHA256_name) { Crypto::Hash::SHA256 sha; - EXPECT_EQ(sha.class_name(), "SHA256"); + EXPECT_EQ(sha.class_name(), "SHA256"sv); } TEST_CASE(test_SHA256_hash_string) @@ -153,7 +153,7 @@ TEST_CASE(test_SHA256_hash_string) u8 result[] { 0x9a, 0xcd, 0x50, 0xf9, 0xa2, 0xaf, 0x37, 0xe4, 0x71, 0xf7, 0x61, 0xc3, 0xfe, 0x7b, 0x8d, 0xea, 0x56, 0x17, 0xe5, 0x1d, 0xac, 0x80, 0x2f, 0xe6, 0xc1, 0x77, 0xb7, 0x4a, 0xbf, 0x0a, 0xbb, 0x5a }; - auto digest = Crypto::Hash::SHA256::hash("Well hello friends"); + auto digest = Crypto::Hash::SHA256::hash("Well hello friends"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0); } @@ -162,14 +162,14 @@ TEST_CASE(test_SHA256_hash_empty_string) u8 result[] { 0xe3, 0xb0, 0xc4, 0x42, 0x98, 0xfc, 0x1c, 0x14, 0x9a, 0xfb, 0xf4, 0xc8, 0x99, 0x6f, 0xb9, 0x24, 0x27, 0xae, 0x41, 0xe4, 0x64, 0x9b, 0x93, 0x4c, 0xa4, 0x95, 0x99, 0x1b, 0x78, 0x52, 0xb8, 0x55 }; - auto digest = Crypto::Hash::SHA256::hash(""); + auto digest = Crypto::Hash::SHA256::hash(""sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA256::digest_size()) == 0); } TEST_CASE(test_SHA384_name) { Crypto::Hash::SHA384 sha; - EXPECT_EQ(sha.class_name(), "SHA384"); + EXPECT_EQ(sha.class_name(), "SHA384"sv); } TEST_CASE(test_SHA384_hash_string) @@ -177,7 +177,7 @@ TEST_CASE(test_SHA384_hash_string) u8 result[] { 0x2f, 0x01, 0x8e, 0x9a, 0x4f, 0xd1, 0x36, 0xb9, 0x0f, 0xcc, 0x21, 0xde, 0x1a, 0xd4, 0x49, 0x51, 0x57, 0x82, 0x86, 0x84, 0x54, 0x09, 0x82, 0x7b, 0x54, 0x56, 0x93, 0xac, 0x2c, 0x46, 0x0c, 0x1f, 0x5e, 0xec, 0xe0, 0xf7, 0x8b, 0x0b, 0x84, 0x27, 0xc8, 0xb8, 0xbe, 0x49, 0xce, 0x8f, 0x1c, 0xff }; - auto digest = Crypto::Hash::SHA384::hash("Well hello friends"); + auto digest = Crypto::Hash::SHA384::hash("Well hello friends"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA384::digest_size()) == 0); } @@ -187,14 +187,14 @@ TEST_CASE(test_SHA384_hash_bug) 0x09, 0x33, 0x0c, 0x33, 0xf7, 0x11, 0x47, 0xe8, 0x3d, 0x19, 0x2f, 0xc7, 0x82, 0xcd, 0x1b, 0x47, 0x53, 0x11, 0x1b, 0x17, 0x3b, 0x3b, 0x05, 0xd2, 0x2f, 0xa0, 0x80, 0x86, 0xe3, 0xb0, 0xf7, 0x12, 0xfc, 0xc7, 0xc7, 0x1a, 0x55, 0x7e, 0x2d, 0xb9, 0x66, 0xc3, 0xe9, 0xfa, 0x91, 0x74, 0x60, 0x39 }; ReadonlyBytes result_bytes { result, 48 }; - auto digest = Crypto::Hash::SHA384::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"); + auto digest = Crypto::Hash::SHA384::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"sv); EXPECT_EQ(result_bytes, digest.bytes()); } TEST_CASE(test_SHA512_name) { Crypto::Hash::SHA512 sha; - EXPECT_EQ(sha.class_name(), "SHA512"); + EXPECT_EQ(sha.class_name(), "SHA512"sv); } TEST_CASE(test_SHA512_hash_string) @@ -202,7 +202,7 @@ TEST_CASE(test_SHA512_hash_string) u8 result[] { 0x00, 0xfe, 0x68, 0x09, 0x71, 0x0e, 0xcb, 0x2b, 0xe9, 0x58, 0x00, 0x13, 0x69, 0x6a, 0x9e, 0x9e, 0xbd, 0x09, 0x1b, 0xfe, 0x14, 0xc9, 0x13, 0x82, 0xc7, 0x40, 0x34, 0xfe, 0xca, 0xe6, 0x87, 0xcb, 0x26, 0x36, 0x92, 0xe6, 0x34, 0x94, 0x3a, 0x11, 0xe5, 0xbb, 0xb5, 0xeb, 0x8e, 0x70, 0xef, 0x64, 0xca, 0xf7, 0x21, 0xb1, 0xde, 0xf2, 0x34, 0x85, 0x6f, 0xa8, 0x56, 0xd8, 0x23, 0xa1, 0x3b, 0x29 }; - auto digest = Crypto::Hash::SHA512::hash("Well hello friends"); + auto digest = Crypto::Hash::SHA512::hash("Well hello friends"sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA512::digest_size()) == 0); } @@ -212,7 +212,7 @@ TEST_CASE(test_SHA512_hash_bug) 0x8e, 0x95, 0x9b, 0x75, 0xda, 0xe3, 0x13, 0xda, 0x8c, 0xf4, 0xf7, 0x28, 0x14, 0xfc, 0x14, 0x3f, 0x8f, 0x77, 0x79, 0xc6, 0xeb, 0x9f, 0x7f, 0xa1, 0x72, 0x99, 0xae, 0xad, 0xb6, 0x88, 0x90, 0x18, 0x50, 0x1d, 0x28, 0x9e, 0x49, 0x00, 0xf7, 0xe4, 0x33, 0x1b, 0x99, 0xde, 0xc4, 0xb5, 0x43, 0x3a, 0xc7, 0xd3, 0x29, 0xee, 0xb6, 0xdd, 0x26, 0x54, 0x5e, 0x96, 0xe5, 0x5b, 0x87, 0x4b, 0xe9, 0x09 }; ReadonlyBytes result_bytes { result, 64 }; - auto digest = Crypto::Hash::SHA512::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"); + auto digest = Crypto::Hash::SHA512::hash("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu"sv); EXPECT_EQ(result_bytes, digest.bytes()); } @@ -221,7 +221,7 @@ TEST_CASE(test_SHA512_hash_empty_string) u8 result[] { 0xcf, 0x83, 0xe1, 0x35, 0x7e, 0xef, 0xb8, 0xbd, 0xf1, 0x54, 0x28, 0x50, 0xd6, 0x6d, 0x80, 0x07, 0xd6, 0x20, 0xe4, 0x05, 0x0b, 0x57, 0x15, 0xdc, 0x83, 0xf4, 0xa9, 0x21, 0xd3, 0x6c, 0xe9, 0xce, 0x47, 0xd0, 0xd1, 0x3c, 0x5d, 0x85, 0xf2, 0xb0, 0xff, 0x83, 0x18, 0xd2, 0x87, 0x7e, 0xec, 0x2f, 0x63, 0xb9, 0x31, 0xbd, 0x47, 0x41, 0x7a, 0x81, 0xa5, 0x38, 0x32, 0x7a, 0xf9, 0x27, 0xda, 0x3e }; - auto digest = Crypto::Hash::SHA512::hash(""); + auto digest = Crypto::Hash::SHA512::hash(""sv); EXPECT(memcmp(result, digest.data, Crypto::Hash::SHA512::digest_size()) == 0); } diff --git a/Tests/LibCrypto/TestRSA.cpp b/Tests/LibCrypto/TestRSA.cpp index 04c72f8f428..56dd4950636 100644 --- a/Tests/LibCrypto/TestRSA.cpp +++ b/Tests/LibCrypto/TestRSA.cpp @@ -55,7 +55,7 @@ joNOYoR5R9z5oX2cpcyykQ58FC2vKKg+x8N6xczG7qO95tw5UQIhAN354CP/FA+uTeJ6KJ+i zCBCl58CjNCzO0s5HTc56el5AiEAsvPKXo5/9gS/S4UzDRP6abq7GreixTfjR8LXidk3FL8C IQCTjYI861Y+hjMnlORkGSdvWlTHUj6gjEOh4TlWeJzQoQIgAxMZOQKtxCZUuxFwzRq4xLRG nrDlBQpuxz7bwSyQO7UCIHrYMnDohgNbwtA5ZpW3H1cKKQQvueWm6sxW9P5sUrZ3 ------END RSA PRIVATE KEY-----)"; +-----END RSA PRIVATE KEY-----)"sv; Crypto::PK::RSA rsa(privkey); if (rsa.public_key().public_exponent() != 65537) { @@ -96,7 +96,7 @@ o+7RC7iOkO+rnzTXwxBSBpXMiUTAIx/hrdfPVxQT+wKBgCh7N3OLIOH6EWcW1fif UoENh8rkt/kzm89G1JLwBhuBIBPXUEZt2dS/xSUempqVqFGONpP87gvqxkMTtgCA 73KXn/cxHWM2kmXyHA3kQlOYw6WHjpldQAxLE+TRHXO2JUtZ09Mu4rVXX7lmwbTm l3vmuDEF3/Bo1C1HTg0xRV/l ------END PRIVATE KEY-----)"; +-----END PRIVATE KEY-----)"sv; Crypto::PK::RSA rsa(privkey); if (rsa.public_key().public_exponent() != 65537) { diff --git a/Tests/LibGL/TestRender.cpp b/Tests/LibGL/TestRender.cpp index 85604fae6a6..4d5448bb49d 100644 --- a/Tests/LibGL/TestRender.cpp +++ b/Tests/LibGL/TestRender.cpp @@ -70,7 +70,7 @@ TEST_CASE(0001_simple_triangle) EXPECT_EQ(glGetError(), 0u); context->present(); - expect_bitmap_equals_reference(context->frontbuffer(), "0001_simple_triangle"); + expect_bitmap_equals_reference(context->frontbuffer(), "0001_simple_triangle"sv); } TEST_CASE(0002_quad_color_interpolation) @@ -92,7 +92,7 @@ TEST_CASE(0002_quad_color_interpolation) EXPECT_EQ(glGetError(), 0u); context->present(); - expect_bitmap_equals_reference(context->frontbuffer(), "0002_quad_color_interpolation"); + expect_bitmap_equals_reference(context->frontbuffer(), "0002_quad_color_interpolation"sv); } TEST_CASE(0003_rect_w_coordinate_regression) @@ -115,7 +115,7 @@ TEST_CASE(0003_rect_w_coordinate_regression) EXPECT_EQ(glGetError(), 0u); context->present(); - expect_bitmap_equals_reference(context->frontbuffer(), "0003_rect_w_coordinate_regression"); + expect_bitmap_equals_reference(context->frontbuffer(), "0003_rect_w_coordinate_regression"sv); } TEST_CASE(0004_points) @@ -145,7 +145,7 @@ TEST_CASE(0004_points) EXPECT_EQ(glGetError(), 0u); context->present(); - expect_bitmap_equals_reference(context->frontbuffer(), "0004_points"); + expect_bitmap_equals_reference(context->frontbuffer(), "0004_points"sv); } TEST_CASE(0005_lines_antialiased) @@ -167,5 +167,5 @@ TEST_CASE(0005_lines_antialiased) EXPECT_EQ(glGetError(), 0u); context->present(); - expect_bitmap_equals_reference(context->frontbuffer(), "0005_lines"); + expect_bitmap_equals_reference(context->frontbuffer(), "0005_lines"sv); } diff --git a/Tests/LibGfx/TestFontHandling.cpp b/Tests/LibGfx/TestFontHandling.cpp index 2efdb070fb0..72ed49460f3 100644 --- a/Tests/LibGfx/TestFontHandling.cpp +++ b/Tests/LibGfx/TestFontHandling.cpp @@ -14,7 +14,7 @@ TEST_CASE(test_fontdatabase_get_by_name) { - char const* name = "Liza 10 400 0"; + auto name = "Liza 10 400 0"sv; auto& font_database = Gfx::FontDatabase::the(); EXPECT(!font_database.get_by_name(name)->name().is_null()); } @@ -55,7 +55,7 @@ TEST_CASE(test_set_name) u8 glyph_width = 1; auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); - char const* name = "my newly created font"; + auto name = "my newly created font"sv; font->set_name(name); EXPECT(!font->name().is_null()); @@ -68,7 +68,7 @@ TEST_CASE(test_set_family) u8 glyph_width = 1; auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); - char const* family = "my newly created font family"; + auto family = "my newly created font family"sv; font->set_family(family); EXPECT(!font->family().is_null()); @@ -105,7 +105,7 @@ TEST_CASE(test_width) u8 glyph_width = 1; auto font = Gfx::BitmapFont::create(glyph_height, glyph_width, true, 256); - EXPECT(font->width("A") == glyph_width); + EXPECT(font->width("A"sv) == glyph_width); } TEST_CASE(test_glyph_or_emoji_width) diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index ce6d0241728..817f7b88e72 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -23,7 +23,7 @@ TEST_CASE(test_bmp) { - auto file = Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgba32-1.bmp").release_value(); + auto file = Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgba32-1.bmp"sv).release_value(); auto bmp = Gfx::BMPImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(bmp.frame_count()); @@ -37,7 +37,7 @@ TEST_CASE(test_bmp) TEST_CASE(test_gif) { - auto file = Core::MappedFile::map("/res/graphics/download-animation.gif").release_value(); + auto file = Core::MappedFile::map("/res/graphics/download-animation.gif"sv).release_value(); auto gif = Gfx::GIFImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(gif.frame_count()); @@ -52,7 +52,7 @@ TEST_CASE(test_gif) TEST_CASE(test_ico) { // FIXME: Use an ico file - auto file = Core::MappedFile::map("/res/graphics/buggie.png").release_value(); + auto file = Core::MappedFile::map("/res/graphics/buggie.png"sv).release_value(); auto ico = Gfx::ICOImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(ico.frame_count()); @@ -65,7 +65,7 @@ TEST_CASE(test_ico) TEST_CASE(test_jpg) { - auto file = Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgb24.jpg").release_value(); + auto file = Core::MappedFile::map("/res/html/misc/bmpsuite_files/rgb24.jpg"sv).release_value(); auto jpg = Gfx::JPGImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(jpg.frame_count()); @@ -79,7 +79,7 @@ TEST_CASE(test_jpg) TEST_CASE(test_pbm) { - auto file = Core::MappedFile::map("/res/html/misc/pbmsuite_files/buggie-raw.pbm").release_value(); + auto file = Core::MappedFile::map("/res/html/misc/pbmsuite_files/buggie-raw.pbm"sv).release_value(); auto pbm = Gfx::PBMImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(pbm.frame_count()); @@ -93,7 +93,7 @@ TEST_CASE(test_pbm) TEST_CASE(test_pgm) { - auto file = Core::MappedFile::map("/res/html/misc/pgmsuite_files/buggie-raw.pgm").release_value(); + auto file = Core::MappedFile::map("/res/html/misc/pgmsuite_files/buggie-raw.pgm"sv).release_value(); auto pgm = Gfx::PGMImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(pgm.frame_count()); @@ -107,7 +107,7 @@ TEST_CASE(test_pgm) TEST_CASE(test_png) { - auto file = Core::MappedFile::map("/res/graphics/buggie.png").release_value(); + auto file = Core::MappedFile::map("/res/graphics/buggie.png"sv).release_value(); auto png = Gfx::PNGImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(png.frame_count()); @@ -121,7 +121,7 @@ TEST_CASE(test_png) TEST_CASE(test_ppm) { - auto file = Core::MappedFile::map("/res/html/misc/ppmsuite_files/buggie-raw.ppm").release_value(); + auto file = Core::MappedFile::map("/res/html/misc/ppmsuite_files/buggie-raw.ppm"sv).release_value(); auto ppm = Gfx::PPMImageDecoderPlugin((u8 const*)file->data(), file->size()); EXPECT(ppm.frame_count()); diff --git a/Tests/LibJS/test-bytecode-js.cpp b/Tests/LibJS/test-bytecode-js.cpp index 3ee794d49a5..56a997565d3 100644 --- a/Tests/LibJS/test-bytecode-js.cpp +++ b/Tests/LibJS/test-bytecode-js.cpp @@ -11,15 +11,15 @@ #include #include -#define SETUP_AND_PARSE(source) \ - auto vm = JS::VM::create(); \ - auto ast_interpreter = JS::Interpreter::create(*vm); \ - \ - auto script_or_error = JS::Script::parse(source, ast_interpreter->realm()); \ - EXPECT(!script_or_error.is_error()); \ - \ - auto script = script_or_error.release_value(); \ - auto const& program = script->parse_node(); \ +#define SETUP_AND_PARSE(source) \ + auto vm = JS::VM::create(); \ + auto ast_interpreter = JS::Interpreter::create(*vm); \ + \ + auto script_or_error = JS::Script::parse(source##sv, ast_interpreter->realm()); \ + EXPECT(!script_or_error.is_error()); \ + \ + auto script = script_or_error.release_value(); \ + auto const& program = script->parse_node(); \ JS::Bytecode::Interpreter bytecode_interpreter(ast_interpreter->global_object(), ast_interpreter->realm()); #define EXPECT_NO_EXCEPTION(executable) \ @@ -110,7 +110,7 @@ TEST_CASE(loading_multiple_files) } { - auto test_file_script_or_error = JS::Script::parse("if (f() !== 'hello') throw new Exception('failed'); ", ast_interpreter->realm()); + auto test_file_script_or_error = JS::Script::parse("if (f() !== 'hello') throw new Exception('failed'); "sv, ast_interpreter->realm()); EXPECT(!test_file_script_or_error.is_error()); auto test_file_script = test_file_script_or_error.release_value(); diff --git a/Tests/LibJS/test-invalid-unicode-js.cpp b/Tests/LibJS/test-invalid-unicode-js.cpp index 75b6682a081..ef073d2e025 100644 --- a/Tests/LibJS/test-invalid-unicode-js.cpp +++ b/Tests/LibJS/test-invalid-unicode-js.cpp @@ -37,7 +37,7 @@ static bool triggers_immediate_unicode_fault(StringView code) TEST_CASE(no_input_only_gives_eof) { - char const* code = ""; + auto code = ""sv; auto lexer = JS::Lexer(code); EXPECT(produces_eof_tokens(lexer)); } @@ -134,7 +134,7 @@ TEST_CASE(long_invalid_unicode_and_valid_code) TEST_CASE(invalid_unicode_after_valid_code_and_before_eof) { - char const* code = "let \xEA\xFD;"; + auto code = "let \xEA\xFD;"sv; auto lexer = JS::Lexer(code); auto let_token = lexer.next(); EXPECT_EQ(let_token.type(), JS::TokenType::Let); diff --git a/Tests/LibJS/test-js.cpp b/Tests/LibJS/test-js.cpp index 7bfc47754ac..9dd5ee00b06 100644 --- a/Tests/LibJS/test-js.cpp +++ b/Tests/LibJS/test-js.cpp @@ -104,18 +104,18 @@ TESTJS_RUN_FILE_FUNCTION(String const& test_file, JS::Interpreter& interpreter, ExplicitPass, } expectation { Pass }; - if (dirname.ends_with("early")) + if (dirname.ends_with("early"sv)) expectation = Early; - else if (dirname.ends_with("fail")) + else if (dirname.ends_with("fail"sv)) expectation = Fail; - else if (dirname.ends_with("pass-explicit")) + else if (dirname.ends_with("pass-explicit"sv)) expectation = ExplicitPass; - else if (dirname.ends_with("pass")) + else if (dirname.ends_with("pass"sv)) expectation = Pass; else return Test::JS::RunFileHookResult::SkipFile; - auto program_type = path.basename().ends_with(".module.js") ? JS::Program::Type::Module : JS::Program::Type::Script; + auto program_type = path.basename().ends_with(".module.js"sv) ? JS::Program::Type::Module : JS::Program::Type::Script; bool parse_succeeded = false; if (program_type == JS::Program::Type::Module) parse_succeeded = !Test::JS::parse_module(test_file, interpreter.realm()).is_error(); diff --git a/Tests/LibM/test-math.cpp b/Tests/LibM/test-math.cpp index 422e7347d55..6898cbc7d00 100644 --- a/Tests/LibM/test-math.cpp +++ b/Tests/LibM/test-math.cpp @@ -130,13 +130,13 @@ template<> struct Formatter : StandardFormatter { ErrorOr format(FormatBuilder& builder, Extractor const& value) { - TRY(builder.put_literal("{")); + TRY(builder.put_literal("{"sv)); TRY(builder.put_u64(value.sign)); - TRY(builder.put_literal(", ")); + TRY(builder.put_literal(", "sv)); TRY(builder.put_u64(value.exponent, 16, true)); - TRY(builder.put_literal(", ")); + TRY(builder.put_literal(", "sv)); TRY(builder.put_u64(value.mantissa, 16, true)); - TRY(builder.put_literal("}")); + TRY(builder.put_literal("}"sv)); return {}; } }; diff --git a/Tests/LibMarkdown/TestCommonmark.cpp b/Tests/LibMarkdown/TestCommonmark.cpp index c45d0c07216..2d2ec547355 100644 --- a/Tests/LibMarkdown/TestCommonmark.cpp +++ b/Tests/LibMarkdown/TestCommonmark.cpp @@ -15,9 +15,9 @@ TEST_SETUP { - auto file_or_error = Core::Stream::File::open("/home/anon/Tests/commonmark.spec.json", Core::Stream::OpenMode::Read); + auto file_or_error = Core::Stream::File::open("/home/anon/Tests/commonmark.spec.json"sv, Core::Stream::OpenMode::Read); if (file_or_error.is_error()) - file_or_error = Core::Stream::File::open("./commonmark.spec.json", Core::Stream::OpenMode::Read); + file_or_error = Core::Stream::File::open("./commonmark.spec.json"sv, Core::Stream::OpenMode::Read); VERIFY(!file_or_error.is_error()); auto file = file_or_error.release_value(); auto file_size = MUST(file->size()); @@ -31,13 +31,13 @@ TEST_SETUP auto testcase = tests[i].as_object(); auto name = String::formatted("{}_ex{}_{}..{}", - testcase.get("section"), - testcase.get("example"), - testcase.get("start_line"), - testcase.get("end_line")); + testcase.get("section"sv), + testcase.get("example"sv), + testcase.get("start_line"sv), + testcase.get("end_line"sv)); - String markdown = testcase.get("markdown").as_string(); - String html = testcase.get("html").as_string(); + String markdown = testcase.get("markdown"sv).as_string(); + String html = testcase.get("html"sv).as_string(); Test::TestSuite::the().add_case(adopt_ref(*new Test::TestCase( name, [markdown, html]() { diff --git a/Tests/LibPDF/TestPDF.cpp b/Tests/LibPDF/TestPDF.cpp index e666b7ec9c9..ecdd7b3f908 100644 --- a/Tests/LibPDF/TestPDF.cpp +++ b/Tests/LibPDF/TestPDF.cpp @@ -13,7 +13,7 @@ TEST_CASE(linearized_pdf) { - auto file = Core::MappedFile::map("linearized.pdf").release_value(); + auto file = Core::MappedFile::map("linearized.pdf"sv).release_value(); auto document = PDF::Document::create(file->bytes()); EXPECT(!document.is_error()); EXPECT(!document.value()->initialize().is_error()); @@ -22,7 +22,7 @@ TEST_CASE(linearized_pdf) TEST_CASE(non_linearized_pdf) { - auto file = Core::MappedFile::map("non-linearized.pdf").release_value(); + auto file = Core::MappedFile::map("non-linearized.pdf"sv).release_value(); auto document = PDF::Document::create(file->bytes()); EXPECT(!document.is_error()); EXPECT(!document.value()->initialize().is_error()); @@ -31,7 +31,7 @@ TEST_CASE(non_linearized_pdf) TEST_CASE(complex_pdf) { - auto file = Core::MappedFile::map("complex.pdf").release_value(); + auto file = Core::MappedFile::map("complex.pdf"sv).release_value(); auto document = PDF::Document::create(file->bytes()); EXPECT(!document.is_error()); EXPECT(!document.value()->initialize().is_error()); diff --git a/Tests/LibRegex/Regex.cpp b/Tests/LibRegex/Regex.cpp index 964ae83ef1c..93a87d35c57 100644 --- a/Tests/LibRegex/Regex.cpp +++ b/Tests/LibRegex/Regex.cpp @@ -96,7 +96,7 @@ TEST_CASE(regex_options_posix) TEST_CASE(regex_lexer) { - Lexer l("/[.*+?^${}()|[\\]\\\\]/g"); + Lexer l("/[.*+?^${}()|[\\]\\\\]/g"sv); EXPECT(l.next().type() == regex::TokenType::Slash); EXPECT(l.next().type() == regex::TokenType::LeftBracket); EXPECT(l.next().type() == regex::TokenType::Period); @@ -149,7 +149,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) // After vertical line b.clear(); - b.append("a|"); + b.append("a|"sv); b.append(ch); pattern = b.build(); l.set_source(pattern); @@ -196,25 +196,25 @@ TEST_CASE(parser_error_vertical_line_used_at_wrong_place) PosixExtended p(l); // First in ere - l.set_source("|asdf"); + l.set_source("|asdf"sv); p.parse(); EXPECT(p.has_error()); EXPECT(p.error() == regex::Error::EmptySubExpression); // Last in ere - l.set_source("asdf|"); + l.set_source("asdf|"sv); p.parse(); EXPECT(p.has_error()); EXPECT(p.error() == regex::Error::EmptySubExpression); // After left parens - l.set_source("(|asdf)"); + l.set_source("(|asdf)"sv); p.parse(); EXPECT(p.has_error()); EXPECT(p.error() == regex::Error::EmptySubExpression); // Proceed right parens - l.set_source("(asdf)|"); + l.set_source("(asdf)|"sv); p.parse(); EXPECT(p.has_error()); EXPECT(p.error() == regex::Error::EmptySubExpression); @@ -224,21 +224,21 @@ TEST_CASE(catch_all_first) { Regex re("^.*$"); RegexResult m; - re.match("Hello World", m); + re.match("Hello World"sv, m); EXPECT(m.count == 1); - EXPECT(re.match("Hello World", m)); + EXPECT(re.match("Hello World"sv, m)); } TEST_CASE(catch_all) { Regex re("^.*$", PosixFlags::Global); - EXPECT(re.has_match("Hello World")); - EXPECT(re.match("Hello World").success); - EXPECT(re.match("Hello World").count == 1); + EXPECT(re.has_match("Hello World"sv)); + EXPECT(re.match("Hello World"sv).success); + EXPECT(re.match("Hello World"sv).count == 1); - EXPECT(has_match("Hello World", re)); - auto res = match("Hello World", re); + EXPECT(has_match("Hello World"sv, re)); + auto res = match("Hello World"sv, re); EXPECT(res.success); EXPECT(res.count == 1); EXPECT(res.matches.size() == 1); @@ -248,7 +248,7 @@ TEST_CASE(catch_all) TEST_CASE(catch_all_again) { Regex re("^.*$", PosixFlags::Extra); - EXPECT_EQ(has_match("Hello World", re), true); + EXPECT_EQ(has_match("Hello World"sv, re), true); } TEST_CASE(char_utf8) @@ -295,14 +295,14 @@ TEST_CASE(catch_all_newline_2) { Regex re("^.*$"); RegexResult result; - result = match("Hello World\nTest\n1234\n", re, PosixFlags::Multiline | PosixFlags::StringCopyMatches); + result = match("Hello World\nTest\n1234\n"sv, re, PosixFlags::Multiline | PosixFlags::StringCopyMatches); EXPECT_EQ(result.success, true); EXPECT_EQ(result.count, 3u); EXPECT_EQ(result.matches.at(0).view, "Hello World"); EXPECT_EQ(result.matches.at(1).view, "Test"); EXPECT_EQ(result.matches.at(2).view, "1234"); - result = match("Hello World\nTest\n1234\n", re); + result = match("Hello World\nTest\n1234\n"sv, re); EXPECT_EQ(result.success, true); EXPECT_EQ(result.count, 1u); EXPECT_EQ(result.matches.at(0).view, "Hello World\nTest\n1234\n"); @@ -334,16 +334,16 @@ TEST_CASE(match_character_class_with_assertion) TEST_CASE(example_for_git_commit) { Regex re("^.*$"); - auto result = re.match("Well, hello friends!\nHello World!"); + auto result = re.match("Well, hello friends!\nHello World!"sv); EXPECT(result.success); EXPECT(result.count == 1); - EXPECT(result.matches.at(0).view.starts_with("Well")); + EXPECT(result.matches.at(0).view.starts_with("Well"sv)); EXPECT(result.matches.at(0).view.length() == 33); - EXPECT(re.has_match("Well,....")); + EXPECT(re.has_match("Well,...."sv)); - result = re.match("Well, hello friends!\nHello World!", PosixFlags::Multiline); + result = re.match("Well, hello friends!\nHello World!"sv, PosixFlags::Multiline); EXPECT(result.success); EXPECT(result.count == 2); @@ -354,8 +354,8 @@ TEST_CASE(example_for_git_commit) TEST_CASE(email_address) { Regex re("^[A-Z0-9a-z._%+-]{1,64}@([A-Za-z0-9-]{1,63}\\.){1,125}[A-Za-z]{2,63}$"); - EXPECT(re.has_match("hello.world@domain.tld")); - EXPECT(re.has_match("this.is.a.very_long_email_address@world.wide.web")); + EXPECT(re.has_match("hello.world@domain.tld"sv)); + EXPECT(re.has_match("this.is.a.very_long_email_address@world.wide.web"sv)); } TEST_CASE(ini_file_entries) @@ -480,16 +480,16 @@ TEST_CASE(simple_period_end_benchmark) { Regex re("hello.$"); RegexResult m; - EXPECT_EQ(re.search("Hello1", m), false); - EXPECT_EQ(re.search("hello1hello1", m), true); - EXPECT_EQ(re.search("hello2hell", m), false); - EXPECT_EQ(re.search("hello?", m), true); + EXPECT_EQ(re.search("Hello1"sv, m), false); + EXPECT_EQ(re.search("hello1hello1"sv, m), true); + EXPECT_EQ(re.search("hello2hell"sv, m), false); + EXPECT_EQ(re.search("hello?"sv, m), true); } TEST_CASE(posix_extended_nested_capture_group) { Regex re("(h(e(?llo)))"); // group 0 -> "hello", group 1 -> "ello", group 2/"llo" -> "llo" - auto result = re.match("hello"); + auto result = re.match("hello"sv); EXPECT(result.success); EXPECT_EQ(result.capture_group_matches.size(), 1u); EXPECT_EQ(result.capture_group_matches[0].size(), 3u); @@ -661,7 +661,7 @@ TEST_CASE(ECMA262_match) { "(a{3}){2}"sv, "aaaabaa"sv, false }, { "(a{4}){2}"sv, "aaaaaaaa"sv }, { "(a{4}){2}"sv, "aaaaaabaa"sv, false }, - { "\\u{4}"sv, "uuuu" }, + { "\\u{4}"sv, "uuuu"sv }, { "(?<=.{3})f"sv, "abcdef"sv, true, (ECMAScriptFlags)regex::AllFlags::Global }, { "(?<=.{3})f"sv, "abc😀ef"sv, true, (ECMAScriptFlags)regex::AllFlags::Global }, // ECMA262, B.1.4. Regular Expression Pattern extensions for browsers @@ -876,7 +876,7 @@ TEST_CASE(replace) TEST_CASE(case_insensitive_match) { Regex re("cd", PosixFlags::Insensitive | PosixFlags::Global); - auto result = re.match("AEKFCD"); + auto result = re.match("AEKFCD"sv); EXPECT_EQ(result.success, true); if (result.success) { @@ -901,7 +901,7 @@ TEST_CASE(theoretically_infinite_loop) }; for (auto& pattern : patterns) { Regex re(pattern); - auto result = re.match(""); + auto result = re.match(""sv); EXPECT_EQ(result.success, true); } } @@ -985,10 +985,10 @@ TEST_CASE(posix_basic_dollar_is_end_anchor) // Ensure that a dollar sign at the end only matches the end of the line. { Regex re("abc$"); - EXPECT_EQ(re.match("123abcdef", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc", PosixFlags::Global).success, true); - EXPECT_EQ(re.match("123abc$def", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc$", PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abcdef"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc"sv, PosixFlags::Global).success, true); + EXPECT_EQ(re.match("123abc$def"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc$"sv, PosixFlags::Global).success, false); } } @@ -997,19 +997,19 @@ TEST_CASE(posix_basic_dollar_is_literal) // Ensure that a dollar sign in the middle is treated as a literal. { Regex re("abc$d"); - EXPECT_EQ(re.match("123abcdef", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc$def", PosixFlags::Global).success, true); - EXPECT_EQ(re.match("123abc$", PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abcdef"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc$def"sv, PosixFlags::Global).success, true); + EXPECT_EQ(re.match("123abc$"sv, PosixFlags::Global).success, false); } // Ensure that a dollar sign is always treated as a literal if escaped, even if at the end of the pattern. { Regex re("abc\\$"); - EXPECT_EQ(re.match("123abcdef", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc", PosixFlags::Global).success, false); - EXPECT_EQ(re.match("123abc$def", PosixFlags::Global).success, true); - EXPECT_EQ(re.match("123abc$", PosixFlags::Global).success, true); + EXPECT_EQ(re.match("123abcdef"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc"sv, PosixFlags::Global).success, false); + EXPECT_EQ(re.match("123abc$def"sv, PosixFlags::Global).success, true); + EXPECT_EQ(re.match("123abc$"sv, PosixFlags::Global).success, true); } } @@ -1020,9 +1020,9 @@ TEST_CASE(negative_lookahead) auto options = ECMAScriptOptions { ECMAScriptFlags::Global }; options.reset_flag((ECMAScriptFlags)regex::AllFlags::Internal_Stateful); Regex re(":(?!\\^\\)|1)", options); - EXPECT_EQ(re.match(":^)").success, false); - EXPECT_EQ(re.match(":1").success, false); - EXPECT_EQ(re.match(":foobar").success, true); + EXPECT_EQ(re.match(":^)"sv).success, false); + EXPECT_EQ(re.match(":1"sv).success, false); + EXPECT_EQ(re.match(":foobar"sv).success, true); } } @@ -1031,7 +1031,7 @@ TEST_CASE(single_match_flag) { // Ensure that only a single match is produced and nothing past that. Regex re("[\\u0008-\\uffff]"sv, ECMAScriptFlags::Global | (ECMAScriptFlags)regex::AllFlags::SingleMatch); - auto result = re.match("ABC"); + auto result = re.match("ABC"sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); EXPECT_EQ(result.matches.first().view.to_string(), "A"sv); @@ -1044,7 +1044,7 @@ TEST_CASE(inversion_state_in_char_class) // #13755, /[\S\s]/.exec("hello") should be [ "h" ], not null. Regex re("[\\S\\s]", ECMAScriptFlags::Global | (ECMAScriptFlags)regex::AllFlags::SingleMatch); - auto result = re.match("hello"); + auto result = re.match("hello"sv); EXPECT_EQ(result.success, true); EXPECT_EQ(result.matches.size(), 1u); EXPECT_EQ(result.matches.first().view.to_string(), "h"sv); diff --git a/Tests/LibRegex/RegexLibC.cpp b/Tests/LibRegex/RegexLibC.cpp index 05bc755613b..00fff1e99f4 100644 --- a/Tests/LibRegex/RegexLibC.cpp +++ b/Tests/LibRegex/RegexLibC.cpp @@ -332,7 +332,7 @@ TEST_CASE(parser_error_special_characters_used_at_wrong_place) // After vertical line b.clear(); - b.append("a|"); + b.append("a|"sv); b.append(ch); pattern = b.build(); EXPECT_EQ(regcomp(®ex, pattern.characters(), REG_EXTENDED), error_code_to_check); diff --git a/Tests/LibSQL/TestSqlExpressionParser.cpp b/Tests/LibSQL/TestSqlExpressionParser.cpp index 03f595959c5..00a8cc71c68 100644 --- a/Tests/LibSQL/TestSqlExpressionParser.cpp +++ b/Tests/LibSQL/TestSqlExpressionParser.cpp @@ -53,9 +53,9 @@ TEST_CASE(numeric_literal) // This is obviously inconsistent. // See the FIXME in lexer.cpp, method consume_exponent() about // solutions. - // EXPECT(parse("1e").is_error()); - // EXPECT(parse("1a").is_error()); - // EXPECT(parse("0x").is_error()); + // EXPECT(parse("1e"sv).is_error()); + // EXPECT(parse("1a"sv).is_error()); + // EXPECT(parse("0x"sv).is_error()); auto validate = [](StringView sql, double expected_value) { auto result = parse(sql); @@ -68,18 +68,18 @@ TEST_CASE(numeric_literal) EXPECT_EQ(literal.value(), expected_value); }; - validate("123", 123); - validate("3.14", 3.14); - validate("0xA", 10); - validate("0xff", 255); - validate("0x100", 256); - validate("1e3", 1000); + validate("123"sv, 123); + validate("3.14"sv, 3.14); + validate("0xA"sv, 10); + validate("0xff"sv, 255); + validate("0x100"sv, 256); + validate("1e3"sv, 1000); } TEST_CASE(string_literal) { - EXPECT(parse("'").is_error()); - EXPECT(parse("'unterminated").is_error()); + EXPECT(parse("'"sv).is_error()); + EXPECT(parse("'unterminated"sv).is_error()); auto validate = [](StringView sql, StringView expected_value) { auto result = parse(sql); @@ -92,16 +92,16 @@ TEST_CASE(string_literal) EXPECT_EQ(literal.value(), expected_value); }; - validate("''", ""); - validate("'hello friends'", "hello friends"); - validate("'hello ''friends'''", "hello 'friends'"); + validate("''"sv, ""sv); + validate("'hello friends'"sv, "hello friends"sv); + validate("'hello ''friends'''"sv, "hello 'friends'"sv); } TEST_CASE(blob_literal) { - EXPECT(parse("x'").is_error()); - EXPECT(parse("x'unterminated").is_error()); - EXPECT(parse("x'NOTHEX'").is_error()); + EXPECT(parse("x'"sv).is_error()); + EXPECT(parse("x'unterminated"sv).is_error()); + EXPECT(parse("x'NOTHEX'"sv).is_error()); auto validate = [](StringView sql, StringView expected_value) { auto result = parse(sql); @@ -114,8 +114,8 @@ TEST_CASE(blob_literal) EXPECT_EQ(literal.value(), expected_value); }; - validate("x''", ""); - validate("x'DEADC0DE'", "DEADC0DE"); + validate("x''"sv, ""sv); + validate("x'DEADC0DE'"sv, "DEADC0DE"sv); } TEST_CASE(null_literal) @@ -128,15 +128,15 @@ TEST_CASE(null_literal) EXPECT(is(*expression)); }; - validate("NULL"); + validate("NULL"sv); } TEST_CASE(column_name) { - EXPECT(parse(".column_name").is_error()); - EXPECT(parse("table_name.").is_error()); - EXPECT(parse("schema_name.table_name.").is_error()); - EXPECT(parse("\"unterminated").is_error()); + EXPECT(parse(".column_name"sv).is_error()); + EXPECT(parse("table_name."sv).is_error()); + EXPECT(parse("schema_name.table_name."sv).is_error()); + EXPECT(parse("\"unterminated"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, StringView expected_column) { auto result = parse(sql); @@ -151,22 +151,22 @@ TEST_CASE(column_name) EXPECT_EQ(column.column_name(), expected_column); }; - validate("column_name", {}, {}, "COLUMN_NAME"); - validate("table_name.column_name", {}, "TABLE_NAME", "COLUMN_NAME"); - validate("schema_name.table_name.column_name", "SCHEMA_NAME", "TABLE_NAME", "COLUMN_NAME"); - validate("\"Column_Name\"", {}, {}, "Column_Name"); - validate("\"Column\n_Name\"", {}, {}, "Column\n_Name"); + validate("column_name"sv, {}, {}, "COLUMN_NAME"sv); + validate("table_name.column_name"sv, {}, "TABLE_NAME"sv, "COLUMN_NAME"sv); + validate("schema_name.table_name.column_name"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "COLUMN_NAME"sv); + validate("\"Column_Name\""sv, {}, {}, "Column_Name"sv); + validate("\"Column\n_Name\""sv, {}, {}, "Column\n_Name"sv); } TEST_CASE(unary_operator) { - EXPECT(parse("-").is_error()); - EXPECT(parse("--").is_error()); - EXPECT(parse("+").is_error()); - EXPECT(parse("++").is_error()); - EXPECT(parse("~").is_error()); - EXPECT(parse("~~").is_error()); - EXPECT(parse("NOT").is_error()); + EXPECT(parse("-"sv).is_error()); + EXPECT(parse("--"sv).is_error()); + EXPECT(parse("+"sv).is_error()); + EXPECT(parse("++"sv).is_error()); + EXPECT(parse("~"sv).is_error()); + EXPECT(parse("~~"sv).is_error()); + EXPECT(parse("NOT"sv).is_error()); auto validate = [](StringView sql, SQL::AST::UnaryOperator expected_operator) { auto result = parse(sql); @@ -182,42 +182,42 @@ TEST_CASE(unary_operator) EXPECT(!is(*secondary_expression)); }; - validate("-15", SQL::AST::UnaryOperator::Minus); - validate("+15", SQL::AST::UnaryOperator::Plus); - validate("~15", SQL::AST::UnaryOperator::BitwiseNot); - validate("NOT 15", SQL::AST::UnaryOperator::Not); + validate("-15"sv, SQL::AST::UnaryOperator::Minus); + validate("+15"sv, SQL::AST::UnaryOperator::Plus); + validate("~15"sv, SQL::AST::UnaryOperator::BitwiseNot); + validate("NOT 15"sv, SQL::AST::UnaryOperator::Not); } TEST_CASE(binary_operator) { HashMap operators { - { "||", SQL::AST::BinaryOperator::Concatenate }, - { "*", SQL::AST::BinaryOperator::Multiplication }, - { "/", SQL::AST::BinaryOperator::Division }, - { "%", SQL::AST::BinaryOperator::Modulo }, - { "+", SQL::AST::BinaryOperator::Plus }, - { "-", SQL::AST::BinaryOperator::Minus }, - { "<<", SQL::AST::BinaryOperator::ShiftLeft }, - { ">>", SQL::AST::BinaryOperator::ShiftRight }, - { "&", SQL::AST::BinaryOperator::BitwiseAnd }, - { "|", SQL::AST::BinaryOperator::BitwiseOr }, - { "<", SQL::AST::BinaryOperator::LessThan }, - { "<=", SQL::AST::BinaryOperator::LessThanEquals }, - { ">", SQL::AST::BinaryOperator::GreaterThan }, - { ">=", SQL::AST::BinaryOperator::GreaterThanEquals }, - { "=", SQL::AST::BinaryOperator::Equals }, - { "==", SQL::AST::BinaryOperator::Equals }, - { "!=", SQL::AST::BinaryOperator::NotEquals }, - { "<>", SQL::AST::BinaryOperator::NotEquals }, - { "AND", SQL::AST::BinaryOperator::And }, - { "OR", SQL::AST::BinaryOperator::Or }, + { "||"sv, SQL::AST::BinaryOperator::Concatenate }, + { "*"sv, SQL::AST::BinaryOperator::Multiplication }, + { "/"sv, SQL::AST::BinaryOperator::Division }, + { "%"sv, SQL::AST::BinaryOperator::Modulo }, + { "+"sv, SQL::AST::BinaryOperator::Plus }, + { "-"sv, SQL::AST::BinaryOperator::Minus }, + { "<<"sv, SQL::AST::BinaryOperator::ShiftLeft }, + { ">>"sv, SQL::AST::BinaryOperator::ShiftRight }, + { "&"sv, SQL::AST::BinaryOperator::BitwiseAnd }, + { "|"sv, SQL::AST::BinaryOperator::BitwiseOr }, + { "<"sv, SQL::AST::BinaryOperator::LessThan }, + { "<="sv, SQL::AST::BinaryOperator::LessThanEquals }, + { ">"sv, SQL::AST::BinaryOperator::GreaterThan }, + { ">="sv, SQL::AST::BinaryOperator::GreaterThanEquals }, + { "="sv, SQL::AST::BinaryOperator::Equals }, + { "=="sv, SQL::AST::BinaryOperator::Equals }, + { "!="sv, SQL::AST::BinaryOperator::NotEquals }, + { "<>"sv, SQL::AST::BinaryOperator::NotEquals }, + { "AND"sv, SQL::AST::BinaryOperator::And }, + { "OR"sv, SQL::AST::BinaryOperator::Or }, }; for (auto op : operators) { EXPECT(parse(op.key).is_error()); StringBuilder builder; - builder.append("1 "); + builder.append("1 "sv); builder.append(op.key); EXPECT(parse(builder.build()).is_error()); @@ -225,7 +225,7 @@ TEST_CASE(binary_operator) if (op.key != "+" && op.key != "-") { // "+1" and "-1" are fine (unary operator). builder.append(op.key); - builder.append(" 1"); + builder.append(" 1"sv); EXPECT(parse(builder.build()).is_error()); } } @@ -245,18 +245,18 @@ TEST_CASE(binary_operator) for (auto op : operators) { StringBuilder builder; - builder.append("1 "); + builder.append("1 "sv); builder.append(op.key); - builder.append(" 1"); + builder.append(" 1"sv); validate(builder.build(), op.value); } } TEST_CASE(chained_expression) { - EXPECT(parse("()").is_error()); - EXPECT(parse("(,)").is_error()); - EXPECT(parse("(15,)").is_error()); + EXPECT(parse("()"sv).is_error()); + EXPECT(parse("(,)"sv).is_error()); + EXPECT(parse("(15,)"sv).is_error()); auto validate = [](StringView sql, size_t expected_chain_size) { auto result = parse(sql); @@ -272,20 +272,20 @@ TEST_CASE(chained_expression) EXPECT(!is(chained_expression)); }; - validate("(15)", 1); - validate("(15, 16)", 2); - validate("(15, 16, column_name)", 3); + validate("(15)"sv, 1); + validate("(15, 16)"sv, 2); + validate("(15, 16, column_name)"sv, 3); } TEST_CASE(cast_expression) { - EXPECT(parse("CAST").is_error()); - EXPECT(parse("CAST (").is_error()); - EXPECT(parse("CAST ()").is_error()); - EXPECT(parse("CAST (15)").is_error()); - EXPECT(parse("CAST (15 AS").is_error()); - EXPECT(parse("CAST (15 AS)").is_error()); - EXPECT(parse("CAST (15 AS int").is_error()); + EXPECT(parse("CAST"sv).is_error()); + EXPECT(parse("CAST ("sv).is_error()); + EXPECT(parse("CAST ()"sv).is_error()); + EXPECT(parse("CAST (15)"sv).is_error()); + EXPECT(parse("CAST (15 AS"sv).is_error()); + EXPECT(parse("CAST (15 AS)"sv).is_error()); + EXPECT(parse("CAST (15 AS int"sv).is_error()); auto validate = [](StringView sql, StringView expected_type_name) { auto result = parse(sql); @@ -303,25 +303,25 @@ TEST_CASE(cast_expression) EXPECT_EQ(type_name->name(), expected_type_name); }; - validate("CAST (15 AS int)", "INT"); + validate("CAST (15 AS int)"sv, "INT"sv); // FIXME The syntax in the test below fails on both sqlite3 and psql (PostgreSQL). // Also fails here because null is interpreted as the NULL keyword and not the // identifier null (which is not a type) - // validate("CAST ('NULL' AS null)", "null"); - validate("CAST (15 AS varchar(255))", "VARCHAR"); + // validate("CAST ('NULL' AS null)"sv, "null"sv); + validate("CAST (15 AS varchar(255))"sv, "VARCHAR"sv); } TEST_CASE(case_expression) { - EXPECT(parse("CASE").is_error()); - EXPECT(parse("CASE END").is_error()); - EXPECT(parse("CASE 15").is_error()); - EXPECT(parse("CASE 15 END").is_error()); - EXPECT(parse("CASE WHEN").is_error()); - EXPECT(parse("CASE WHEN THEN").is_error()); - EXPECT(parse("CASE WHEN 15 THEN 16").is_error()); - EXPECT(parse("CASE WHEN 15 THEN 16 ELSE").is_error()); - EXPECT(parse("CASE WHEN 15 THEN 16 ELSE END").is_error()); + EXPECT(parse("CASE"sv).is_error()); + EXPECT(parse("CASE END"sv).is_error()); + EXPECT(parse("CASE 15"sv).is_error()); + EXPECT(parse("CASE 15 END"sv).is_error()); + EXPECT(parse("CASE WHEN"sv).is_error()); + EXPECT(parse("CASE WHEN THEN"sv).is_error()); + EXPECT(parse("CASE WHEN 15 THEN 16"sv).is_error()); + EXPECT(parse("CASE WHEN 15 THEN 16 ELSE"sv).is_error()); + EXPECT(parse("CASE WHEN 15 THEN 16 ELSE END"sv).is_error()); auto validate = [](StringView sql, bool expect_case_expression, size_t expected_when_then_size, bool expect_else_expression) { auto result = parse(sql); @@ -350,31 +350,31 @@ TEST_CASE(case_expression) EXPECT(!is(*else_expression)); }; - validate("CASE WHEN 16 THEN 17 END", false, 1, false); - validate("CASE WHEN 16 THEN 17 WHEN 18 THEN 19 END", false, 2, false); - validate("CASE WHEN 16 THEN 17 WHEN 18 THEN 19 ELSE 20 END", false, 2, true); + validate("CASE WHEN 16 THEN 17 END"sv, false, 1, false); + validate("CASE WHEN 16 THEN 17 WHEN 18 THEN 19 END"sv, false, 2, false); + validate("CASE WHEN 16 THEN 17 WHEN 18 THEN 19 ELSE 20 END"sv, false, 2, true); - validate("CASE 15 WHEN 16 THEN 17 END", true, 1, false); - validate("CASE 15 WHEN 16 THEN 17 WHEN 18 THEN 19 END", true, 2, false); - validate("CASE 15 WHEN 16 THEN 17 WHEN 18 THEN 19 ELSE 20 END", true, 2, true); + validate("CASE 15 WHEN 16 THEN 17 END"sv, true, 1, false); + validate("CASE 15 WHEN 16 THEN 17 WHEN 18 THEN 19 END"sv, true, 2, false); + validate("CASE 15 WHEN 16 THEN 17 WHEN 18 THEN 19 ELSE 20 END"sv, true, 2, true); } TEST_CASE(exists_expression) { - EXPECT(parse("EXISTS").is_error()); - EXPECT(parse("EXISTS (").is_error()); - EXPECT(parse("EXISTS (SELECT").is_error()); - EXPECT(parse("EXISTS (SELECT)").is_error()); - EXPECT(parse("EXISTS (SELECT * FROM table_name").is_error()); - EXPECT(parse("NOT EXISTS").is_error()); - EXPECT(parse("NOT EXISTS (").is_error()); - EXPECT(parse("NOT EXISTS (SELECT").is_error()); - EXPECT(parse("NOT EXISTS (SELECT)").is_error()); - EXPECT(parse("NOT EXISTS (SELECT * FROM table_name").is_error()); - EXPECT(parse("(").is_error()); - EXPECT(parse("(SELECT").is_error()); - EXPECT(parse("(SELECT)").is_error()); - EXPECT(parse("(SELECT * FROM table_name").is_error()); + EXPECT(parse("EXISTS"sv).is_error()); + EXPECT(parse("EXISTS ("sv).is_error()); + EXPECT(parse("EXISTS (SELECT"sv).is_error()); + EXPECT(parse("EXISTS (SELECT)"sv).is_error()); + EXPECT(parse("EXISTS (SELECT * FROM table_name"sv).is_error()); + EXPECT(parse("NOT EXISTS"sv).is_error()); + EXPECT(parse("NOT EXISTS ("sv).is_error()); + EXPECT(parse("NOT EXISTS (SELECT"sv).is_error()); + EXPECT(parse("NOT EXISTS (SELECT)"sv).is_error()); + EXPECT(parse("NOT EXISTS (SELECT * FROM table_name"sv).is_error()); + EXPECT(parse("("sv).is_error()); + EXPECT(parse("(SELECT"sv).is_error()); + EXPECT(parse("(SELECT)"sv).is_error()); + EXPECT(parse("(SELECT * FROM table_name"sv).is_error()); auto validate = [](StringView sql, bool expected_invert_expression) { auto result = parse(sql); @@ -387,16 +387,16 @@ TEST_CASE(exists_expression) EXPECT_EQ(exists.invert_expression(), expected_invert_expression); }; - validate("EXISTS (SELECT * FROM table_name)", false); - validate("NOT EXISTS (SELECT * FROM table_name)", true); - validate("(SELECT * FROM table_name)", false); + validate("EXISTS (SELECT * FROM table_name)"sv, false); + validate("NOT EXISTS (SELECT * FROM table_name)"sv, true); + validate("(SELECT * FROM table_name)"sv, false); } TEST_CASE(collate_expression) { - EXPECT(parse("COLLATE").is_error()); - EXPECT(parse("COLLATE name").is_error()); - EXPECT(parse("15 COLLATE").is_error()); + EXPECT(parse("COLLATE"sv).is_error()); + EXPECT(parse("COLLATE name"sv).is_error()); + EXPECT(parse("15 COLLATE"sv).is_error()); auto validate = [](StringView sql, StringView expected_collation_name) { auto result = parse(sql); @@ -410,18 +410,18 @@ TEST_CASE(collate_expression) EXPECT_EQ(collate.collation_name(), expected_collation_name); }; - validate("15 COLLATE fifteen", "FIFTEEN"); - validate("(15, 16) COLLATE \"chain\"", "chain"); + validate("15 COLLATE fifteen"sv, "FIFTEEN"sv); + validate("(15, 16) COLLATE \"chain\""sv, "chain"sv); } TEST_CASE(is_expression) { - EXPECT(parse("IS").is_error()); - EXPECT(parse("IS 1").is_error()); - EXPECT(parse("1 IS").is_error()); - EXPECT(parse("IS NOT").is_error()); - EXPECT(parse("IS NOT 1").is_error()); - EXPECT(parse("1 IS NOT").is_error()); + EXPECT(parse("IS"sv).is_error()); + EXPECT(parse("IS 1"sv).is_error()); + EXPECT(parse("1 IS"sv).is_error()); + EXPECT(parse("IS NOT"sv).is_error()); + EXPECT(parse("IS NOT 1"sv).is_error()); + EXPECT(parse("1 IS NOT"sv).is_error()); auto validate = [](StringView sql, bool expected_invert_expression) { auto result = parse(sql); @@ -436,30 +436,30 @@ TEST_CASE(is_expression) EXPECT_EQ(is_.invert_expression(), expected_invert_expression); }; - validate("1 IS NULL", false); - validate("1 IS NOT NULL", true); + validate("1 IS NULL"sv, false); + validate("1 IS NOT NULL"sv, true); } TEST_CASE(match_expression) { HashMap operators { - { "LIKE", SQL::AST::MatchOperator::Like }, - { "GLOB", SQL::AST::MatchOperator::Glob }, - { "MATCH", SQL::AST::MatchOperator::Match }, - { "REGEXP", SQL::AST::MatchOperator::Regexp }, + { "LIKE"sv, SQL::AST::MatchOperator::Like }, + { "GLOB"sv, SQL::AST::MatchOperator::Glob }, + { "MATCH"sv, SQL::AST::MatchOperator::Match }, + { "REGEXP"sv, SQL::AST::MatchOperator::Regexp }, }; for (auto op : operators) { EXPECT(parse(op.key).is_error()); StringBuilder builder; - builder.append("1 "); + builder.append("1 "sv); builder.append(op.key); EXPECT(parse(builder.build()).is_error()); builder.clear(); builder.append(op.key); - builder.append(" 1"); + builder.append(" 1"sv); EXPECT(parse(builder.build()).is_error()); } @@ -480,30 +480,30 @@ TEST_CASE(match_expression) for (auto op : operators) { StringBuilder builder; - builder.append("1 "); + builder.append("1 "sv); builder.append(op.key); - builder.append(" 1"); + builder.append(" 1"sv); validate(builder.build(), op.value, false, false); builder.clear(); - builder.append("1 NOT "); + builder.append("1 NOT "sv); builder.append(op.key); - builder.append(" 1"); + builder.append(" 1"sv); validate(builder.build(), op.value, true, false); builder.clear(); - builder.append("1 NOT "); + builder.append("1 NOT "sv); builder.append(op.key); - builder.append(" 1 ESCAPE '+'"); + builder.append(" 1 ESCAPE '+'"sv); validate(builder.build(), op.value, true, true); } } TEST_CASE(null_expression) { - EXPECT(parse("ISNULL").is_error()); - EXPECT(parse("NOTNULL").is_error()); - EXPECT(parse("15 NOT").is_error()); + EXPECT(parse("ISNULL"sv).is_error()); + EXPECT(parse("NOTNULL"sv).is_error()); + EXPECT(parse("15 NOT"sv).is_error()); auto validate = [](StringView sql, bool expected_invert_expression) { auto result = parse(sql); @@ -516,21 +516,21 @@ TEST_CASE(null_expression) EXPECT_EQ(null.invert_expression(), expected_invert_expression); }; - validate("15 ISNULL", false); - validate("15 NOTNULL", true); - validate("15 NOT NULL", true); + validate("15 ISNULL"sv, false); + validate("15 NOTNULL"sv, true); + validate("15 NOT NULL"sv, true); } TEST_CASE(between_expression) { - EXPECT(parse("BETWEEN").is_error()); - EXPECT(parse("NOT BETWEEN").is_error()); - EXPECT(parse("BETWEEN 10 AND 20").is_error()); - EXPECT(parse("NOT BETWEEN 10 AND 20").is_error()); - EXPECT(parse("15 BETWEEN 10").is_error()); - EXPECT(parse("15 BETWEEN 10 AND").is_error()); - EXPECT(parse("15 BETWEEN AND 20").is_error()); - EXPECT(parse("15 BETWEEN 10 OR 20").is_error()); + EXPECT(parse("BETWEEN"sv).is_error()); + EXPECT(parse("NOT BETWEEN"sv).is_error()); + EXPECT(parse("BETWEEN 10 AND 20"sv).is_error()); + EXPECT(parse("NOT BETWEEN 10 AND 20"sv).is_error()); + EXPECT(parse("15 BETWEEN 10"sv).is_error()); + EXPECT(parse("15 BETWEEN 10 AND"sv).is_error()); + EXPECT(parse("15 BETWEEN AND 20"sv).is_error()); + EXPECT(parse("15 BETWEEN 10 OR 20"sv).is_error()); auto validate = [](StringView sql, bool expected_invert_expression) { auto result = parse(sql); @@ -546,16 +546,16 @@ TEST_CASE(between_expression) EXPECT_EQ(between.invert_expression(), expected_invert_expression); }; - validate("15 BETWEEN 10 AND 20", false); - validate("15 NOT BETWEEN 10 AND 20", true); + validate("15 BETWEEN 10 AND 20"sv, false); + validate("15 NOT BETWEEN 10 AND 20"sv, true); } TEST_CASE(in_table_expression) { - EXPECT(parse("IN").is_error()); - EXPECT(parse("IN table_name").is_error()); - EXPECT(parse("NOT IN").is_error()); - EXPECT(parse("NOT IN table_name").is_error()); + EXPECT(parse("IN"sv).is_error()); + EXPECT(parse("IN table_name"sv).is_error()); + EXPECT(parse("NOT IN"sv).is_error()); + EXPECT(parse("NOT IN table_name"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, bool expected_invert_expression) { auto result = parse(sql); @@ -571,17 +571,17 @@ TEST_CASE(in_table_expression) EXPECT_EQ(in.invert_expression(), expected_invert_expression); }; - validate("15 IN table_name", {}, "TABLE_NAME", false); - validate("15 IN schema_name.table_name", "SCHEMA_NAME", "TABLE_NAME", false); + validate("15 IN table_name"sv, {}, "TABLE_NAME"sv, false); + validate("15 IN schema_name.table_name"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, false); - validate("15 NOT IN table_name", {}, "TABLE_NAME", true); - validate("15 NOT IN schema_name.table_name", "SCHEMA_NAME", "TABLE_NAME", true); + validate("15 NOT IN table_name"sv, {}, "TABLE_NAME"sv, true); + validate("15 NOT IN schema_name.table_name"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, true); } TEST_CASE(in_chained_expression) { - EXPECT(parse("IN ()").is_error()); - EXPECT(parse("NOT IN ()").is_error()); + EXPECT(parse("IN ()"sv).is_error()); + EXPECT(parse("NOT IN ()"sv).is_error()); auto validate = [](StringView sql, size_t expected_chain_size, bool expected_invert_expression) { auto result = parse(sql); @@ -599,21 +599,21 @@ TEST_CASE(in_chained_expression) EXPECT(!is(chained_expression)); }; - validate("15 IN ()", 0, false); - validate("15 IN (15)", 1, false); - validate("15 IN (15, 16)", 2, false); + validate("15 IN ()"sv, 0, false); + validate("15 IN (15)"sv, 1, false); + validate("15 IN (15, 16)"sv, 2, false); - validate("15 NOT IN ()", 0, true); - validate("15 NOT IN (15)", 1, true); - validate("15 NOT IN (15, 16)", 2, true); + validate("15 NOT IN ()"sv, 0, true); + validate("15 NOT IN (15)"sv, 1, true); + validate("15 NOT IN (15, 16)"sv, 2, true); } TEST_CASE(in_selection_expression) { - EXPECT(parse("IN (SELECT)").is_error()); - EXPECT(parse("IN (SELECT * FROM table_name, SELECT * FROM table_name);").is_error()); - EXPECT(parse("NOT IN (SELECT)").is_error()); - EXPECT(parse("NOT IN (SELECT * FROM table_name, SELECT * FROM table_name);").is_error()); + EXPECT(parse("IN (SELECT)"sv).is_error()); + EXPECT(parse("IN (SELECT * FROM table_name, SELECT * FROM table_name);"sv).is_error()); + EXPECT(parse("NOT IN (SELECT)"sv).is_error()); + EXPECT(parse("NOT IN (SELECT * FROM table_name, SELECT * FROM table_name);"sv).is_error()); auto validate = [](StringView sql, bool expected_invert_expression) { auto result = parse(sql); @@ -627,8 +627,8 @@ TEST_CASE(in_selection_expression) EXPECT_EQ(in.invert_expression(), expected_invert_expression); }; - validate("15 IN (SELECT * FROM table_name)", false); - validate("15 NOT IN (SELECT * FROM table_name)", true); + validate("15 IN (SELECT * FROM table_name)"sv, false); + validate("15 NOT IN (SELECT * FROM table_name)"sv, true); } TEST_CASE(expression_tree_depth_limit) diff --git a/Tests/LibSQL/TestSqlStatementParser.cpp b/Tests/LibSQL/TestSqlStatementParser.cpp index a8ea995fca3..6659ac1ea2c 100644 --- a/Tests/LibSQL/TestSqlStatementParser.cpp +++ b/Tests/LibSQL/TestSqlStatementParser.cpp @@ -37,27 +37,27 @@ ParseResult parse(StringView sql) TEST_CASE(create_table) { - EXPECT(parse("CREATE TABLE").is_error()); - EXPECT(parse("CREATE TABLE test").is_error()); - EXPECT(parse("CREATE TABLE test ()").is_error()); - EXPECT(parse("CREATE TABLE test ();").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 ").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 )").is_error()); - EXPECT(parse("CREATE TABLE IF test ( column1 );").is_error()); - EXPECT(parse("CREATE TABLE IF NOT test ( column1 );").is_error()); - EXPECT(parse("CREATE TABLE AS;").is_error()); - EXPECT(parse("CREATE TABLE AS SELECT;").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar()").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(abc)").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(123 )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(123, )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(123, ) )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(.) )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(.abc) )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(0x) )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 varchar(0xzzz) )").is_error()); - EXPECT(parse("CREATE TABLE test ( column1 int ) AS SELECT * FROM table_name;").is_error()); - EXPECT(parse("CREATE TABLE test AS SELECT * FROM table_name ( column1 int ) ;").is_error()); + EXPECT(parse("CREATE TABLE"sv).is_error()); + EXPECT(parse("CREATE TABLE test"sv).is_error()); + EXPECT(parse("CREATE TABLE test ()"sv).is_error()); + EXPECT(parse("CREATE TABLE test ();"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 "sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 )"sv).is_error()); + EXPECT(parse("CREATE TABLE IF test ( column1 );"sv).is_error()); + EXPECT(parse("CREATE TABLE IF NOT test ( column1 );"sv).is_error()); + EXPECT(parse("CREATE TABLE AS;"sv).is_error()); + EXPECT(parse("CREATE TABLE AS SELECT;"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar()"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(abc)"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(123 )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(123, )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(123, ) )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(.) )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(.abc) )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(0x) )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 varchar(0xzzz) )"sv).is_error()); + EXPECT(parse("CREATE TABLE test ( column1 int ) AS SELECT * FROM table_name;"sv).is_error()); + EXPECT(parse("CREATE TABLE test AS SELECT * FROM table_name ( column1 int ) ;"sv).is_error()); struct Column { StringView name; @@ -109,42 +109,42 @@ TEST_CASE(create_table) } }; - validate("CREATE TABLE test ( column1 );", {}, "TEST", { { "COLUMN1", "BLOB" } }); - validate("Create Table test ( column1 );", {}, "TEST", { { "COLUMN1", "BLOB" } }); - validate(R"(CREATE TABLE "test" ( "column1" );)", {}, "test", { { "column1", "BLOB" } }); - validate(R"(CREATE TABLE "te""st" ( "co""lumn1" );)", {}, "te\"st", { { "co\"lumn1", "BLOB" } }); - validate("CREATE TABLE schema_name.test ( column1 );", "SCHEMA_NAME", "TEST", { { "COLUMN1", "BLOB" } }); - validate("CREATE TABLE \"schema\".test ( column1 );", "schema", "TEST", { { "COLUMN1", "BLOB" } }); - validate("CREATE TEMP TABLE test ( column1 );", {}, "TEST", { { "COLUMN1", "BLOB" } }, true, true); - validate("CREATE TEMPORARY TABLE test ( column1 );", {}, "TEST", { { "COLUMN1", "BLOB" } }, true, true); - validate("CREATE TABLE IF NOT EXISTS test ( column1 );", {}, "TEST", { { "COLUMN1", "BLOB" } }, false, false); + validate("CREATE TABLE test ( column1 );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }); + validate("Create Table test ( column1 );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }); + validate(R"(CREATE TABLE "test" ( "column1" );)"sv, {}, "test"sv, { { "column1"sv, "BLOB"sv } }); + validate(R"(CREATE TABLE "te""st" ( "co""lumn1" );)"sv, {}, "te\"st"sv, { { "co\"lumn1"sv, "BLOB"sv } }); + validate("CREATE TABLE schema_name.test ( column1 );"sv, "SCHEMA_NAME"sv, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }); + validate("CREATE TABLE \"schema\".test ( column1 );"sv, "schema"sv, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }); + validate("CREATE TEMP TABLE test ( column1 );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }, true, true); + validate("CREATE TEMPORARY TABLE test ( column1 );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }, true, true); + validate("CREATE TABLE IF NOT EXISTS test ( column1 );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "BLOB"sv } }, false, false); - validate("CREATE TABLE test AS SELECT * FROM table_name;", {}, "TEST", {}); + validate("CREATE TABLE test AS SELECT * FROM table_name;"sv, {}, "TEST"sv, {}); - validate("CREATE TABLE test ( column1 int );", {}, "TEST", { { "COLUMN1", "INT" } }); - validate("CREATE TABLE test ( column1 varchar );", {}, "TEST", { { "COLUMN1", "VARCHAR" } }); - validate("CREATE TABLE test ( column1 varchar(255) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 255 } } }); - validate("CREATE TABLE test ( column1 varchar(255, 123) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 255, 123 } } }); - validate("CREATE TABLE test ( column1 varchar(255, -123) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 255, -123 } } }); - validate("CREATE TABLE test ( column1 varchar(0xff) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 255 } } }); - validate("CREATE TABLE test ( column1 varchar(3.14) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 3.14 } } }); - validate("CREATE TABLE test ( column1 varchar(1e3) );", {}, "TEST", { { "COLUMN1", "VARCHAR", { 1000 } } }); + validate("CREATE TABLE test ( column1 int );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "INT"sv } }); + validate("CREATE TABLE test ( column1 varchar );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv } }); + validate("CREATE TABLE test ( column1 varchar(255) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 255 } } }); + validate("CREATE TABLE test ( column1 varchar(255, 123) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 255, 123 } } }); + validate("CREATE TABLE test ( column1 varchar(255, -123) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 255, -123 } } }); + validate("CREATE TABLE test ( column1 varchar(0xff) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 255 } } }); + validate("CREATE TABLE test ( column1 varchar(3.14) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 3.14 } } }); + validate("CREATE TABLE test ( column1 varchar(1e3) );"sv, {}, "TEST"sv, { { "COLUMN1"sv, "VARCHAR"sv, { 1000 } } }); } TEST_CASE(alter_table) { // This test case only contains common error cases of the AlterTable subclasses. - EXPECT(parse("ALTER").is_error()); - EXPECT(parse("ALTER TABLE").is_error()); - EXPECT(parse("ALTER TABLE table_name").is_error()); - EXPECT(parse("ALTER TABLE table_name;").is_error()); + EXPECT(parse("ALTER"sv).is_error()); + EXPECT(parse("ALTER TABLE"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name;"sv).is_error()); } TEST_CASE(alter_table_rename_table) { - EXPECT(parse("ALTER TABLE table_name RENAME").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME TO").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME TO new_table").is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME TO"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME TO new_table"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, StringView expected_new_table) { auto result = parse(sql); @@ -159,20 +159,20 @@ TEST_CASE(alter_table_rename_table) EXPECT_EQ(alter.new_table_name(), expected_new_table); }; - validate("ALTER TABLE table_name RENAME TO new_table;", {}, "TABLE_NAME", "NEW_TABLE"); - validate("ALTER TABLE schema_name.table_name RENAME TO new_table;", "SCHEMA_NAME", "TABLE_NAME", "NEW_TABLE"); + validate("ALTER TABLE table_name RENAME TO new_table;"sv, {}, "TABLE_NAME"sv, "NEW_TABLE"sv); + validate("ALTER TABLE schema_name.table_name RENAME TO new_table;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "NEW_TABLE"sv); } TEST_CASE(alter_table_rename_column) { - EXPECT(parse("ALTER TABLE table_name RENAME").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME COLUMN").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name TO").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name TO new_column").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME column_name").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME column_name TO").is_error()); - EXPECT(parse("ALTER TABLE table_name RENAME column_name TO new_column").is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME COLUMN"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name TO"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME COLUMN column_name TO new_column"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME column_name"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME column_name TO"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name RENAME column_name TO new_column"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, StringView expected_column, StringView expected_new_column) { auto result = parse(sql); @@ -188,17 +188,17 @@ TEST_CASE(alter_table_rename_column) EXPECT_EQ(alter.new_column_name(), expected_new_column); }; - validate("ALTER TABLE table_name RENAME column_name TO new_column;", {}, "TABLE_NAME", "COLUMN_NAME", "NEW_COLUMN"); - validate("ALTER TABLE table_name RENAME COLUMN column_name TO new_column;", {}, "TABLE_NAME", "COLUMN_NAME", "NEW_COLUMN"); - validate("ALTER TABLE schema_name.table_name RENAME column_name TO new_column;", "SCHEMA_NAME", "TABLE_NAME", "COLUMN_NAME", "NEW_COLUMN"); - validate("ALTER TABLE schema_name.table_name RENAME COLUMN column_name TO new_column;", "SCHEMA_NAME", "TABLE_NAME", "COLUMN_NAME", "NEW_COLUMN"); + validate("ALTER TABLE table_name RENAME column_name TO new_column;"sv, {}, "TABLE_NAME"sv, "COLUMN_NAME"sv, "NEW_COLUMN"sv); + validate("ALTER TABLE table_name RENAME COLUMN column_name TO new_column;"sv, {}, "TABLE_NAME"sv, "COLUMN_NAME"sv, "NEW_COLUMN"sv); + validate("ALTER TABLE schema_name.table_name RENAME column_name TO new_column;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "COLUMN_NAME"sv, "NEW_COLUMN"sv); + validate("ALTER TABLE schema_name.table_name RENAME COLUMN column_name TO new_column;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "COLUMN_NAME"sv, "NEW_COLUMN"sv); } TEST_CASE(alter_table_add_column) { - EXPECT(parse("ALTER TABLE table_name ADD").is_error()); - EXPECT(parse("ALTER TABLE table_name ADD COLUMN").is_error()); - EXPECT(parse("ALTER TABLE table_name ADD COLUMN column_name").is_error()); + EXPECT(parse("ALTER TABLE table_name ADD"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name ADD COLUMN"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name ADD COLUMN column_name"sv).is_error()); struct Column { StringView name; @@ -233,25 +233,25 @@ TEST_CASE(alter_table_add_column) } }; - validate("ALTER TABLE test ADD column1;", {}, "TEST", { "COLUMN1", "BLOB" }); - validate("ALTER TABLE test ADD column1 int;", {}, "TEST", { "COLUMN1", "INT" }); - validate("ALTER TABLE test ADD column1 varchar;", {}, "TEST", { "COLUMN1", "VARCHAR" }); - validate("ALTER TABLE test ADD column1 varchar(255);", {}, "TEST", { "COLUMN1", "VARCHAR", { 255 } }); - validate("ALTER TABLE test ADD column1 varchar(255, 123);", {}, "TEST", { "COLUMN1", "VARCHAR", { 255, 123 } }); + validate("ALTER TABLE test ADD column1;"sv, {}, "TEST"sv, { "COLUMN1"sv, "BLOB"sv }); + validate("ALTER TABLE test ADD column1 int;"sv, {}, "TEST"sv, { "COLUMN1"sv, "INT"sv }); + validate("ALTER TABLE test ADD column1 varchar;"sv, {}, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv }); + validate("ALTER TABLE test ADD column1 varchar(255);"sv, {}, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv, { 255 } }); + validate("ALTER TABLE test ADD column1 varchar(255, 123);"sv, {}, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv, { 255, 123 } }); - validate("ALTER TABLE schema_name.test ADD COLUMN column1;", "SCHEMA_NAME", "TEST", { "COLUMN1", "BLOB" }); - validate("ALTER TABLE schema_name.test ADD COLUMN column1 int;", "SCHEMA_NAME", "TEST", { "COLUMN1", "INT" }); - validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar;", "SCHEMA_NAME", "TEST", { "COLUMN1", "VARCHAR" }); - validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar(255);", "SCHEMA_NAME", "TEST", { "COLUMN1", "VARCHAR", { 255 } }); - validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar(255, 123);", "SCHEMA_NAME", "TEST", { "COLUMN1", "VARCHAR", { 255, 123 } }); + validate("ALTER TABLE schema_name.test ADD COLUMN column1;"sv, "SCHEMA_NAME"sv, "TEST"sv, { "COLUMN1"sv, "BLOB"sv }); + validate("ALTER TABLE schema_name.test ADD COLUMN column1 int;"sv, "SCHEMA_NAME"sv, "TEST"sv, { "COLUMN1"sv, "INT"sv }); + validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar;"sv, "SCHEMA_NAME"sv, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv }); + validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar(255);"sv, "SCHEMA_NAME"sv, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv, { 255 } }); + validate("ALTER TABLE schema_name.test ADD COLUMN column1 varchar(255, 123);"sv, "SCHEMA_NAME"sv, "TEST"sv, { "COLUMN1"sv, "VARCHAR"sv, { 255, 123 } }); } TEST_CASE(alter_table_drop_column) { - EXPECT(parse("ALTER TABLE table_name DROP").is_error()); - EXPECT(parse("ALTER TABLE table_name DROP COLUMN").is_error()); - EXPECT(parse("ALTER TABLE table_name DROP column_name").is_error()); - EXPECT(parse("ALTER TABLE table_name DROP COLUMN column_name").is_error()); + EXPECT(parse("ALTER TABLE table_name DROP"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name DROP COLUMN"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name DROP column_name"sv).is_error()); + EXPECT(parse("ALTER TABLE table_name DROP COLUMN column_name"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, StringView expected_column) { auto result = parse(sql); @@ -266,18 +266,18 @@ TEST_CASE(alter_table_drop_column) EXPECT_EQ(alter.column_name(), expected_column); }; - validate("ALTER TABLE table_name DROP column_name;", {}, "TABLE_NAME", "COLUMN_NAME"); - validate("ALTER TABLE table_name DROP COLUMN column_name;", {}, "TABLE_NAME", "COLUMN_NAME"); - validate("ALTER TABLE schema_name.table_name DROP column_name;", "SCHEMA_NAME", "TABLE_NAME", "COLUMN_NAME"); - validate("ALTER TABLE schema_name.table_name DROP COLUMN column_name;", "SCHEMA_NAME", "TABLE_NAME", "COLUMN_NAME"); + validate("ALTER TABLE table_name DROP column_name;"sv, {}, "TABLE_NAME"sv, "COLUMN_NAME"sv); + validate("ALTER TABLE table_name DROP COLUMN column_name;"sv, {}, "TABLE_NAME"sv, "COLUMN_NAME"sv); + validate("ALTER TABLE schema_name.table_name DROP column_name;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "COLUMN_NAME"sv); + validate("ALTER TABLE schema_name.table_name DROP COLUMN column_name;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "COLUMN_NAME"sv); } TEST_CASE(drop_table) { - EXPECT(parse("DROP").is_error()); - EXPECT(parse("DROP TABLE").is_error()); - EXPECT(parse("DROP TABLE test").is_error()); - EXPECT(parse("DROP TABLE IF test;").is_error()); + EXPECT(parse("DROP"sv).is_error()); + EXPECT(parse("DROP TABLE"sv).is_error()); + EXPECT(parse("DROP TABLE test"sv).is_error()); + EXPECT(parse("DROP TABLE IF test;"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, bool expected_is_error_if_table_does_not_exist = true) { auto result = parse(sql); @@ -292,25 +292,25 @@ TEST_CASE(drop_table) EXPECT_EQ(table.is_error_if_table_does_not_exist(), expected_is_error_if_table_does_not_exist); }; - validate("DROP TABLE test;", {}, "TEST"); - validate("DROP TABLE schema_name.test;", "SCHEMA_NAME", "TEST"); - validate("DROP TABLE IF EXISTS test;", {}, "TEST", false); + validate("DROP TABLE test;"sv, {}, "TEST"sv); + validate("DROP TABLE schema_name.test;"sv, "SCHEMA_NAME"sv, "TEST"sv); + validate("DROP TABLE IF EXISTS test;"sv, {}, "TEST"sv, false); } TEST_CASE(insert) { - EXPECT(parse("INSERT").is_error()); - EXPECT(parse("INSERT INTO").is_error()); - EXPECT(parse("INSERT INTO table_name").is_error()); - EXPECT(parse("INSERT INTO table_name (column_name)").is_error()); - EXPECT(parse("INSERT INTO table_name (column_name, ) DEFAULT VALUES;").is_error()); - EXPECT(parse("INSERT INTO table_name VALUES").is_error()); - EXPECT(parse("INSERT INTO table_name VALUES ();").is_error()); - EXPECT(parse("INSERT INTO table_name VALUES (1)").is_error()); - EXPECT(parse("INSERT INTO table_name SELECT").is_error()); - EXPECT(parse("INSERT INTO table_name SELECT * from table_name").is_error()); - EXPECT(parse("INSERT OR INTO table_name DEFAULT VALUES;").is_error()); - EXPECT(parse("INSERT OR foo INTO table_name DEFAULT VALUES;").is_error()); + EXPECT(parse("INSERT"sv).is_error()); + EXPECT(parse("INSERT INTO"sv).is_error()); + EXPECT(parse("INSERT INTO table_name"sv).is_error()); + EXPECT(parse("INSERT INTO table_name (column_name)"sv).is_error()); + EXPECT(parse("INSERT INTO table_name (column_name, ) DEFAULT VALUES;"sv).is_error()); + EXPECT(parse("INSERT INTO table_name VALUES"sv).is_error()); + EXPECT(parse("INSERT INTO table_name VALUES ();"sv).is_error()); + EXPECT(parse("INSERT INTO table_name VALUES (1)"sv).is_error()); + EXPECT(parse("INSERT INTO table_name SELECT"sv).is_error()); + EXPECT(parse("INSERT INTO table_name SELECT * from table_name"sv).is_error()); + EXPECT(parse("INSERT OR INTO table_name DEFAULT VALUES;"sv).is_error()); + EXPECT(parse("INSERT OR foo INTO table_name DEFAULT VALUES;"sv).is_error()); auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector expected_column_names, Vector expected_chain_sizes, bool expect_select_statement) { auto result = parse(sql); @@ -349,48 +349,48 @@ TEST_CASE(insert) EXPECT_EQ(insert.default_values(), expected_chain_sizes.is_empty() && !expect_select_statement); }; - validate("INSERT OR ABORT INTO table_name DEFAULT VALUES;", SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME", {}, {}, {}, false); - validate("INSERT OR FAIL INTO table_name DEFAULT VALUES;", SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME", {}, {}, {}, false); - validate("INSERT OR IGNORE INTO table_name DEFAULT VALUES;", SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME", {}, {}, {}, false); - validate("INSERT OR REPLACE INTO table_name DEFAULT VALUES;", SQL::AST::ConflictResolution::Replace, {}, "TABLE_NAME", {}, {}, {}, false); - validate("INSERT OR ROLLBACK INTO table_name DEFAULT VALUES;", SQL::AST::ConflictResolution::Rollback, {}, "TABLE_NAME", {}, {}, {}, false); + validate("INSERT OR ABORT INTO table_name DEFAULT VALUES;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT OR FAIL INTO table_name DEFAULT VALUES;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT OR IGNORE INTO table_name DEFAULT VALUES;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT OR REPLACE INTO table_name DEFAULT VALUES;"sv, SQL::AST::ConflictResolution::Replace, {}, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT OR ROLLBACK INTO table_name DEFAULT VALUES;"sv, SQL::AST::ConflictResolution::Rollback, {}, "TABLE_NAME"sv, {}, {}, {}, false); auto resolution = SQL::AST::ConflictResolution::Abort; - validate("INSERT INTO table_name DEFAULT VALUES;", resolution, {}, "TABLE_NAME", {}, {}, {}, false); - validate("INSERT INTO schema_name.table_name DEFAULT VALUES;", resolution, "SCHEMA_NAME", "TABLE_NAME", {}, {}, {}, false); - validate("INSERT INTO table_name AS foo DEFAULT VALUES;", resolution, {}, "TABLE_NAME", "FOO", {}, {}, false); + validate("INSERT INTO table_name DEFAULT VALUES;"sv, resolution, {}, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT INTO schema_name.table_name DEFAULT VALUES;"sv, resolution, "SCHEMA_NAME"sv, "TABLE_NAME"sv, {}, {}, {}, false); + validate("INSERT INTO table_name AS foo DEFAULT VALUES;"sv, resolution, {}, "TABLE_NAME"sv, "FOO"sv, {}, {}, false); - validate("INSERT INTO table_name (column_name) DEFAULT VALUES;", resolution, {}, "TABLE_NAME", {}, { "COLUMN_NAME" }, {}, false); - validate("INSERT INTO table_name (column1, column2) DEFAULT VALUES;", resolution, {}, "TABLE_NAME", {}, { "COLUMN1", "COLUMN2" }, {}, false); + validate("INSERT INTO table_name (column_name) DEFAULT VALUES;"sv, resolution, {}, "TABLE_NAME"sv, {}, { "COLUMN_NAME"sv }, {}, false); + validate("INSERT INTO table_name (column1, column2) DEFAULT VALUES;"sv, resolution, {}, "TABLE_NAME"sv, {}, { "COLUMN1"sv, "COLUMN2"sv }, {}, false); - validate("INSERT INTO table_name VALUES (1);", resolution, {}, "TABLE_NAME", {}, {}, { 1 }, false); - validate("INSERT INTO table_name VALUES (1, 2);", resolution, {}, "TABLE_NAME", {}, {}, { 2 }, false); - validate("INSERT INTO table_name VALUES (1, 2), (3, 4, 5);", resolution, {}, "TABLE_NAME", {}, {}, { 2, 3 }, false); + validate("INSERT INTO table_name VALUES (1);"sv, resolution, {}, "TABLE_NAME"sv, {}, {}, { 1 }, false); + validate("INSERT INTO table_name VALUES (1, 2);"sv, resolution, {}, "TABLE_NAME"sv, {}, {}, { 2 }, false); + validate("INSERT INTO table_name VALUES (1, 2), (3, 4, 5);"sv, resolution, {}, "TABLE_NAME"sv, {}, {}, { 2, 3 }, false); - validate("INSERT INTO table_name SELECT * FROM table_name;", resolution, {}, "TABLE_NAME", {}, {}, {}, true); + validate("INSERT INTO table_name SELECT * FROM table_name;"sv, resolution, {}, "TABLE_NAME"sv, {}, {}, {}, true); } TEST_CASE(update) { - EXPECT(parse("UPDATE").is_error()); - EXPECT(parse("UPDATE table_name").is_error()); - EXPECT(parse("UPDATE table_name SET").is_error()); - EXPECT(parse("UPDATE table_name SET column_name").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4, ;").is_error()); - EXPECT(parse("UPDATE table_name SET (column_name)=4").is_error()); - EXPECT(parse("UPDATE table_name SET (column_name)=4, ;").is_error()); - EXPECT(parse("UPDATE table_name SET (column_name, )=4;").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 FROM").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 FROM table_name").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 WHERE").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 WHERE 1==1").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING *").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING column_name").is_error()); - EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING column_name AS").is_error()); - EXPECT(parse("UPDATE OR table_name SET column_name=4;").is_error()); - EXPECT(parse("UPDATE OR foo table_name SET column_name=4;").is_error()); + EXPECT(parse("UPDATE"sv).is_error()); + EXPECT(parse("UPDATE table_name"sv).is_error()); + EXPECT(parse("UPDATE table_name SET"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4, ;"sv).is_error()); + EXPECT(parse("UPDATE table_name SET (column_name)=4"sv).is_error()); + EXPECT(parse("UPDATE table_name SET (column_name)=4, ;"sv).is_error()); + EXPECT(parse("UPDATE table_name SET (column_name, )=4;"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 FROM"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 FROM table_name"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 WHERE"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 WHERE 1==1"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING *"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING column_name"sv).is_error()); + EXPECT(parse("UPDATE table_name SET column_name=4 RETURNING column_name AS"sv).is_error()); + EXPECT(parse("UPDATE OR table_name SET column_name=4;"sv).is_error()); + EXPECT(parse("UPDATE OR foo table_name SET column_name=4;"sv).is_error()); auto validate = [](StringView sql, SQL::AST::ConflictResolution expected_conflict_resolution, StringView expected_schema, StringView expected_table, StringView expected_alias, Vector> expected_update_columns, bool expect_where_clause, bool expect_returning_clause, Vector expected_returned_column_aliases) { auto result = parse(sql); @@ -440,41 +440,41 @@ TEST_CASE(update) }; Vector> update_columns { { "COLUMN_NAME" } }; - validate("UPDATE OR ABORT table_name SET column_name=1;", SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE OR FAIL table_name SET column_name=1;", SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE OR IGNORE table_name SET column_name=1;", SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE OR REPLACE table_name SET column_name=1;", SQL::AST::ConflictResolution::Replace, {}, "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE OR ROLLBACK table_name SET column_name=1;", SQL::AST::ConflictResolution::Rollback, {}, "TABLE_NAME", {}, update_columns, false, false, {}); + validate("UPDATE OR ABORT table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Abort, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE OR FAIL table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Fail, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE OR IGNORE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Ignore, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE OR REPLACE table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Replace, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE OR ROLLBACK table_name SET column_name=1;"sv, SQL::AST::ConflictResolution::Rollback, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); auto resolution = SQL::AST::ConflictResolution::Abort; - validate("UPDATE table_name SET column_name=1;", resolution, {}, "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE schema_name.table_name SET column_name=1;", resolution, "SCHEMA_NAME", "TABLE_NAME", {}, update_columns, false, false, {}); - validate("UPDATE table_name AS foo SET column_name=1;", resolution, {}, "TABLE_NAME", "FOO", update_columns, false, false, {}); + validate("UPDATE table_name SET column_name=1;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE schema_name.table_name SET column_name=1;"sv, resolution, "SCHEMA_NAME"sv, "TABLE_NAME"sv, {}, update_columns, false, false, {}); + validate("UPDATE table_name AS foo SET column_name=1;"sv, resolution, {}, "TABLE_NAME"sv, "FOO"sv, update_columns, false, false, {}); - validate("UPDATE table_name SET column_name=1;", resolution, {}, "TABLE_NAME", {}, { { "COLUMN_NAME" } }, false, false, {}); - validate("UPDATE table_name SET column1=1, column2=2;", resolution, {}, "TABLE_NAME", {}, { { "COLUMN1" }, { "COLUMN2" } }, false, false, {}); - validate("UPDATE table_name SET (column1, column2)=1, column3=2;", resolution, {}, "TABLE_NAME", {}, { { "COLUMN1", "COLUMN2" }, { "COLUMN3" } }, false, false, {}); + validate("UPDATE table_name SET column_name=1;"sv, resolution, {}, "TABLE_NAME"sv, {}, { { "COLUMN_NAME"sv } }, false, false, {}); + validate("UPDATE table_name SET column1=1, column2=2;"sv, resolution, {}, "TABLE_NAME"sv, {}, { { "COLUMN1"sv }, { "COLUMN2"sv } }, false, false, {}); + validate("UPDATE table_name SET (column1, column2)=1, column3=2;"sv, resolution, {}, "TABLE_NAME"sv, {}, { { "COLUMN1"sv, "COLUMN2"sv }, { "COLUMN3"sv } }, false, false, {}); - validate("UPDATE table_name SET column_name=1 WHERE 1==1;", resolution, {}, "TABLE_NAME", {}, update_columns, true, false, {}); + validate("UPDATE table_name SET column_name=1 WHERE 1==1;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, true, false, {}); - validate("UPDATE table_name SET column_name=1 RETURNING *;", resolution, {}, "TABLE_NAME", {}, update_columns, false, true, {}); - validate("UPDATE table_name SET column_name=1 RETURNING column_name;", resolution, {}, "TABLE_NAME", {}, update_columns, false, true, { {} }); - validate("UPDATE table_name SET column_name=1 RETURNING column_name AS alias;", resolution, {}, "TABLE_NAME", {}, update_columns, false, true, { "ALIAS" }); - validate("UPDATE table_name SET column_name=1 RETURNING column1 AS alias1, column2 AS alias2;", resolution, {}, "TABLE_NAME", {}, update_columns, false, true, { "ALIAS1", "ALIAS2" }); + validate("UPDATE table_name SET column_name=1 RETURNING *;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, false, true, {}); + validate("UPDATE table_name SET column_name=1 RETURNING column_name;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, false, true, { {} }); + validate("UPDATE table_name SET column_name=1 RETURNING column_name AS alias;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, false, true, { "ALIAS"sv }); + validate("UPDATE table_name SET column_name=1 RETURNING column1 AS alias1, column2 AS alias2;"sv, resolution, {}, "TABLE_NAME"sv, {}, update_columns, false, true, { "ALIAS1"sv, "ALIAS2"sv }); } TEST_CASE(delete_) { - EXPECT(parse("DELETE").is_error()); - EXPECT(parse("DELETE FROM").is_error()); - EXPECT(parse("DELETE FROM table_name").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE 15").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING *").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING column_name").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING column_name AS;").is_error()); - EXPECT(parse("DELETE FROM table_name WHERE (');").is_error()); + EXPECT(parse("DELETE"sv).is_error()); + EXPECT(parse("DELETE FROM"sv).is_error()); + EXPECT(parse("DELETE FROM table_name"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE 15"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING *"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING column_name"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE 15 RETURNING column_name AS;"sv).is_error()); + EXPECT(parse("DELETE FROM table_name WHERE (');"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table, StringView expected_alias, bool expect_where_clause, bool expect_returning_clause, Vector expected_returned_column_aliases) { auto result = parse(sql); @@ -510,50 +510,50 @@ TEST_CASE(delete_) } }; - validate("DELETE FROM table_name;", {}, "TABLE_NAME", {}, false, false, {}); - validate("DELETE FROM schema_name.table_name;", "SCHEMA_NAME", "TABLE_NAME", {}, false, false, {}); - validate("DELETE FROM schema_name.table_name AS alias;", "SCHEMA_NAME", "TABLE_NAME", "ALIAS", false, false, {}); - validate("DELETE FROM table_name WHERE (1 == 1);", {}, "TABLE_NAME", {}, true, false, {}); - validate("DELETE FROM table_name RETURNING *;", {}, "TABLE_NAME", {}, false, true, {}); - validate("DELETE FROM table_name RETURNING column_name;", {}, "TABLE_NAME", {}, false, true, { {} }); - validate("DELETE FROM table_name RETURNING column_name AS alias;", {}, "TABLE_NAME", {}, false, true, { "ALIAS" }); - validate("DELETE FROM table_name RETURNING column1 AS alias1, column2 AS alias2;", {}, "TABLE_NAME", {}, false, true, { "ALIAS1", "ALIAS2" }); + validate("DELETE FROM table_name;"sv, {}, "TABLE_NAME"sv, {}, false, false, {}); + validate("DELETE FROM schema_name.table_name;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, {}, false, false, {}); + validate("DELETE FROM schema_name.table_name AS alias;"sv, "SCHEMA_NAME"sv, "TABLE_NAME"sv, "ALIAS"sv, false, false, {}); + validate("DELETE FROM table_name WHERE (1 == 1);"sv, {}, "TABLE_NAME"sv, {}, true, false, {}); + validate("DELETE FROM table_name RETURNING *;"sv, {}, "TABLE_NAME"sv, {}, false, true, {}); + validate("DELETE FROM table_name RETURNING column_name;"sv, {}, "TABLE_NAME"sv, {}, false, true, { {} }); + validate("DELETE FROM table_name RETURNING column_name AS alias;"sv, {}, "TABLE_NAME"sv, {}, false, true, { "ALIAS"sv }); + validate("DELETE FROM table_name RETURNING column1 AS alias1, column2 AS alias2;"sv, {}, "TABLE_NAME"sv, {}, false, true, { "ALIAS1"sv, "ALIAS2"sv }); } TEST_CASE(select) { - EXPECT(parse("SELECT").is_error()); - EXPECT(parse("SELECT;").is_error()); - EXPECT(parse("SELECT DISTINCT;").is_error()); - EXPECT(parse("SELECT ALL;").is_error()); - EXPECT(parse("SELECT *").is_error()); - EXPECT(parse("SELECT * FROM;").is_error()); - EXPECT(parse("SELECT table_name. FROM table_name;").is_error()); - EXPECT(parse("SELECT column_name AS FROM table_name;").is_error()); - EXPECT(parse("SELECT * FROM (").is_error()); - EXPECT(parse("SELECT * FROM ()").is_error()); - EXPECT(parse("SELECT * FROM ();").is_error()); - EXPECT(parse("SELECT * FROM (table_name1)").is_error()); - EXPECT(parse("SELECT * FROM (table_name1, )").is_error()); - EXPECT(parse("SELECT * FROM (table_name1, table_name2)").is_error()); - EXPECT(parse("SELECT * FROM table_name").is_error()); - EXPECT(parse("SELECT * FROM table_name AS;").is_error()); - EXPECT(parse("SELECT * FROM table_name WHERE;").is_error()); - EXPECT(parse("SELECT * FROM table_name WHERE 1 ==1").is_error()); - EXPECT(parse("SELECT * FROM table_name GROUP;").is_error()); - EXPECT(parse("SELECT * FROM table_name GROUP BY;").is_error()); - EXPECT(parse("SELECT * FROM table_name GROUP BY column_name").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER:").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER BY column_name").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER BY column_name COLLATE:").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER BY column_name COLLATE collation").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER BY column_name NULLS;").is_error()); - EXPECT(parse("SELECT * FROM table_name ORDER BY column_name NULLS SECOND;").is_error()); - EXPECT(parse("SELECT * FROM table_name LIMIT;").is_error()); - EXPECT(parse("SELECT * FROM table_name LIMIT 12").is_error()); - EXPECT(parse("SELECT * FROM table_name LIMIT 12 OFFSET;").is_error()); - EXPECT(parse("SELECT * FROM table_name LIMIT 12 OFFSET 15").is_error()); - EXPECT(parse("SELECT * FROM table_name LIMIT 15, 16;").is_error()); + EXPECT(parse("SELECT"sv).is_error()); + EXPECT(parse("SELECT;"sv).is_error()); + EXPECT(parse("SELECT DISTINCT;"sv).is_error()); + EXPECT(parse("SELECT ALL;"sv).is_error()); + EXPECT(parse("SELECT *"sv).is_error()); + EXPECT(parse("SELECT * FROM;"sv).is_error()); + EXPECT(parse("SELECT table_name. FROM table_name;"sv).is_error()); + EXPECT(parse("SELECT column_name AS FROM table_name;"sv).is_error()); + EXPECT(parse("SELECT * FROM ("sv).is_error()); + EXPECT(parse("SELECT * FROM ()"sv).is_error()); + EXPECT(parse("SELECT * FROM ();"sv).is_error()); + EXPECT(parse("SELECT * FROM (table_name1)"sv).is_error()); + EXPECT(parse("SELECT * FROM (table_name1, )"sv).is_error()); + EXPECT(parse("SELECT * FROM (table_name1, table_name2)"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name AS;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name WHERE;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name WHERE 1 ==1"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name GROUP;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name GROUP BY;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name GROUP BY column_name"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER:"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER BY column_name"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER BY column_name COLLATE:"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER BY column_name COLLATE collation"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER BY column_name NULLS;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name ORDER BY column_name NULLS SECOND;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name LIMIT;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name LIMIT 12"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name LIMIT 12 OFFSET;"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name LIMIT 12 OFFSET 15"sv).is_error()); + EXPECT(parse("SELECT * FROM table_name LIMIT 15, 16;"sv).is_error()); struct Type { SQL::AST::ResultType type; @@ -655,51 +655,51 @@ TEST_CASE(select) }; Vector all { { SQL::AST::ResultType::All } }; - Vector from { { {}, "TABLE_NAME", {} } }; + Vector from { { {}, "TABLE_NAME"sv, {} } }; - validate("SELECT * FROM table_name;", { { SQL::AST::ResultType::All } }, from, false, 0, false, {}, false, false); - validate("SELECT table_name.* FROM table_name;", { { SQL::AST::ResultType::Table, "TABLE_NAME" } }, from, false, 0, false, {}, false, false); - validate("SELECT column_name AS alias FROM table_name;", { { SQL::AST::ResultType::Expression, "ALIAS" } }, from, false, 0, false, {}, false, false); - validate("SELECT table_name.column_name AS alias FROM table_name;", { { SQL::AST::ResultType::Expression, "ALIAS" } }, from, false, 0, false, {}, false, false); - validate("SELECT schema_name.table_name.column_name AS alias FROM table_name;", { { SQL::AST::ResultType::Expression, "ALIAS" } }, from, false, 0, false, {}, false, false); - validate("SELECT column_name AS alias, *, table_name.* FROM table_name;", { { SQL::AST::ResultType::Expression, "ALIAS" }, { SQL::AST::ResultType::All }, { SQL::AST::ResultType::Table, "TABLE_NAME" } }, from, false, 0, false, {}, false, false); + validate("SELECT * FROM table_name;"sv, { { SQL::AST::ResultType::All } }, from, false, 0, false, {}, false, false); + validate("SELECT table_name.* FROM table_name;"sv, { { SQL::AST::ResultType::Table, "TABLE_NAME"sv } }, from, false, 0, false, {}, false, false); + validate("SELECT column_name AS alias FROM table_name;"sv, { { SQL::AST::ResultType::Expression, "ALIAS"sv } }, from, false, 0, false, {}, false, false); + validate("SELECT table_name.column_name AS alias FROM table_name;"sv, { { SQL::AST::ResultType::Expression, "ALIAS"sv } }, from, false, 0, false, {}, false, false); + validate("SELECT schema_name.table_name.column_name AS alias FROM table_name;"sv, { { SQL::AST::ResultType::Expression, "ALIAS"sv } }, from, false, 0, false, {}, false, false); + validate("SELECT column_name AS alias, *, table_name.* FROM table_name;"sv, { { SQL::AST::ResultType::Expression, "ALIAS"sv }, { SQL::AST::ResultType::All }, { SQL::AST::ResultType::Table, "TABLE_NAME"sv } }, from, false, 0, false, {}, false, false); - validate("SELECT * FROM table_name;", all, { { {}, "TABLE_NAME", {} } }, false, 0, false, {}, false, false); - validate("SELECT * FROM schema_name.table_name;", all, { { "SCHEMA_NAME", "TABLE_NAME", {} } }, false, 0, false, {}, false, false); - validate("SELECT * FROM schema_name.table_name AS alias;", all, { { "SCHEMA_NAME", "TABLE_NAME", "ALIAS" } }, false, 0, false, {}, false, false); - validate("SELECT * FROM schema_name.table_name AS alias, table_name2, table_name3 AS table_name4;", all, { { "SCHEMA_NAME", "TABLE_NAME", "ALIAS" }, { {}, "TABLE_NAME2", {} }, { {}, "TABLE_NAME3", "TABLE_NAME4" } }, false, 0, false, {}, false, false); + validate("SELECT * FROM table_name;"sv, all, { { {}, "TABLE_NAME"sv, {} } }, false, 0, false, {}, false, false); + validate("SELECT * FROM schema_name.table_name;"sv, all, { { "SCHEMA_NAME"sv, "TABLE_NAME"sv, {} } }, false, 0, false, {}, false, false); + validate("SELECT * FROM schema_name.table_name AS alias;"sv, all, { { "SCHEMA_NAME"sv, "TABLE_NAME"sv, "ALIAS"sv } }, false, 0, false, {}, false, false); + validate("SELECT * FROM schema_name.table_name AS alias, table_name2, table_name3 AS table_name4;"sv, all, { { "SCHEMA_NAME"sv, "TABLE_NAME"sv, "ALIAS"sv }, { {}, "TABLE_NAME2"sv, {} }, { {}, "TABLE_NAME3"sv, "TABLE_NAME4"sv } }, false, 0, false, {}, false, false); - validate("SELECT * FROM table_name WHERE column_name IS NOT NULL;", all, from, true, 0, false, {}, false, false); + validate("SELECT * FROM table_name WHERE column_name IS NOT NULL;"sv, all, from, true, 0, false, {}, false, false); - validate("SELECT * FROM table_name GROUP BY column_name;", all, from, false, 1, false, {}, false, false); - validate("SELECT * FROM table_name GROUP BY column1, column2, column3;", all, from, false, 3, false, {}, false, false); - validate("SELECT * FROM table_name GROUP BY column_name HAVING 'abc';", all, from, false, 1, true, {}, false, false); + validate("SELECT * FROM table_name GROUP BY column_name;"sv, all, from, false, 1, false, {}, false, false); + validate("SELECT * FROM table_name GROUP BY column1, column2, column3;"sv, all, from, false, 3, false, {}, false, false); + validate("SELECT * FROM table_name GROUP BY column_name HAVING 'abc';"sv, all, from, false, 1, true, {}, false, false); - validate("SELECT * FROM table_name ORDER BY column_name;", all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First } }, false, false); - validate("SELECT * FROM table_name ORDER BY column_name COLLATE collation;", all, from, false, 0, false, { { "COLLATION", SQL::Order::Ascending, SQL::Nulls::First } }, false, false); - validate("SELECT * FROM table_name ORDER BY column_name ASC;", all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First } }, false, false); - validate("SELECT * FROM table_name ORDER BY column_name DESC;", all, from, false, 0, false, { { {}, SQL::Order::Descending, SQL::Nulls::Last } }, false, false); - validate("SELECT * FROM table_name ORDER BY column_name ASC NULLS LAST;", all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::Last } }, false, false); - validate("SELECT * FROM table_name ORDER BY column_name DESC NULLS FIRST;", all, from, false, 0, false, { { {}, SQL::Order::Descending, SQL::Nulls::First } }, false, false); - validate("SELECT * FROM table_name ORDER BY column1, column2 DESC, column3 NULLS LAST;", all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First }, { {}, SQL::Order::Descending, SQL::Nulls::Last }, { {}, SQL::Order::Ascending, SQL::Nulls::Last } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name;"sv, all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name COLLATE collation;"sv, all, from, false, 0, false, { { "COLLATION"sv, SQL::Order::Ascending, SQL::Nulls::First } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name ASC;"sv, all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name DESC;"sv, all, from, false, 0, false, { { {}, SQL::Order::Descending, SQL::Nulls::Last } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name ASC NULLS LAST;"sv, all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::Last } }, false, false); + validate("SELECT * FROM table_name ORDER BY column_name DESC NULLS FIRST;"sv, all, from, false, 0, false, { { {}, SQL::Order::Descending, SQL::Nulls::First } }, false, false); + validate("SELECT * FROM table_name ORDER BY column1, column2 DESC, column3 NULLS LAST;"sv, all, from, false, 0, false, { { {}, SQL::Order::Ascending, SQL::Nulls::First }, { {}, SQL::Order::Descending, SQL::Nulls::Last }, { {}, SQL::Order::Ascending, SQL::Nulls::Last } }, false, false); - validate("SELECT * FROM table_name LIMIT 15;", all, from, false, 0, false, {}, true, false); - validate("SELECT * FROM table_name LIMIT 15 OFFSET 16;", all, from, false, 0, false, {}, true, true); + validate("SELECT * FROM table_name LIMIT 15;"sv, all, from, false, 0, false, {}, true, false); + validate("SELECT * FROM table_name LIMIT 15 OFFSET 16;"sv, all, from, false, 0, false, {}, true, true); } TEST_CASE(common_table_expression) { - EXPECT(parse("WITH").is_error()); - EXPECT(parse("WITH;").is_error()); - EXPECT(parse("WITH DELETE FROM table_name;").is_error()); - EXPECT(parse("WITH table_name DELETE FROM table_name;").is_error()); - EXPECT(parse("WITH table_name AS DELETE FROM table_name;").is_error()); - EXPECT(parse("WITH RECURSIVE table_name DELETE FROM table_name;").is_error()); - EXPECT(parse("WITH RECURSIVE table_name AS DELETE FROM table_name;").is_error()); + EXPECT(parse("WITH"sv).is_error()); + EXPECT(parse("WITH;"sv).is_error()); + EXPECT(parse("WITH DELETE FROM table_name;"sv).is_error()); + EXPECT(parse("WITH table_name DELETE FROM table_name;"sv).is_error()); + EXPECT(parse("WITH table_name AS DELETE FROM table_name;"sv).is_error()); + EXPECT(parse("WITH RECURSIVE table_name DELETE FROM table_name;"sv).is_error()); + EXPECT(parse("WITH RECURSIVE table_name AS DELETE FROM table_name;"sv).is_error()); // Below are otherwise valid common-table-expressions, but attached to statements which do not allow them. - EXPECT(parse("WITH table_name AS (SELECT * AS TABLE) CREATE TABLE test ( column1 );").is_error()); - EXPECT(parse("WITH table_name AS (SELECT * FROM table_name) DROP TABLE test;").is_error()); + EXPECT(parse("WITH table_name AS (SELECT * AS TABLE) CREATE TABLE test ( column1 );"sv).is_error()); + EXPECT(parse("WITH table_name AS (SELECT * FROM table_name) DROP TABLE test;"sv).is_error()); struct SelectedTableList { struct SelectedTable { @@ -739,25 +739,25 @@ TEST_CASE(common_table_expression) } }; - validate("WITH table_name AS (SELECT * FROM table_name) DELETE FROM table_name;", { false, { { "TABLE_NAME" } } }); - validate("WITH table_name (column_name) AS (SELECT * FROM table_name) DELETE FROM table_name;", { false, { { "TABLE_NAME", { "COLUMN_NAME" } } } }); - validate("WITH table_name (column1, column2) AS (SELECT * FROM table_name) DELETE FROM table_name;", { false, { { "TABLE_NAME", { "COLUMN1", "COLUMN2" } } } }); - validate("WITH RECURSIVE table_name AS (SELECT * FROM table_name) DELETE FROM table_name;", { true, { { "TABLE_NAME", {} } } }); + validate("WITH table_name AS (SELECT * FROM table_name) DELETE FROM table_name;"sv, { false, { { "TABLE_NAME"sv } } }); + validate("WITH table_name (column_name) AS (SELECT * FROM table_name) DELETE FROM table_name;"sv, { false, { { "TABLE_NAME"sv, { "COLUMN_NAME"sv } } } }); + validate("WITH table_name (column1, column2) AS (SELECT * FROM table_name) DELETE FROM table_name;"sv, { false, { { "TABLE_NAME"sv, { "COLUMN1"sv, "COLUMN2"sv } } } }); + validate("WITH RECURSIVE table_name AS (SELECT * FROM table_name) DELETE FROM table_name;"sv, { true, { { "TABLE_NAME"sv, {} } } }); } TEST_CASE(nested_subquery_limit) { auto subquery = String::formatted("{:(^{}}table_name{:)^{}}", "", SQL::AST::Limits::maximum_subquery_depth - 1, "", SQL::AST::Limits::maximum_subquery_depth - 1); - EXPECT(!parse(String::formatted("SELECT * FROM {};", subquery)).is_error()); - EXPECT(parse(String::formatted("SELECT * FROM ({});", subquery)).is_error()); + EXPECT(!parse(String::formatted("SELECT * FROM {};"sv, subquery)).is_error()); + EXPECT(parse(String::formatted("SELECT * FROM ({});"sv, subquery)).is_error()); } TEST_CASE(describe_table) { - EXPECT(parse("DESCRIBE").is_error()); - EXPECT(parse("DESCRIBE;").is_error()); - EXPECT(parse("DESCRIBE TABLE;").is_error()); - EXPECT(parse("DESCRIBE table_name;").is_error()); + EXPECT(parse("DESCRIBE"sv).is_error()); + EXPECT(parse("DESCRIBE;"sv).is_error()); + EXPECT(parse("DESCRIBE TABLE;"sv).is_error()); + EXPECT(parse("DESCRIBE table_name;"sv).is_error()); auto validate = [](StringView sql, StringView expected_schema, StringView expected_table) { auto result = parse(sql); @@ -773,6 +773,6 @@ TEST_CASE(describe_table) EXPECT_EQ(describe_table_statement.qualified_table_name()->table_name(), expected_table); }; - validate("DESCRIBE TABLE TableName;", {}, "TABLENAME"); - validate("DESCRIBE TABLE SchemaName.TableName;", "SCHEMANAME", "TABLENAME"); + validate("DESCRIBE TABLE TableName;"sv, {}, "TABLENAME"sv); + validate("DESCRIBE TABLE SchemaName.TableName;"sv, "SCHEMANAME"sv, "TABLENAME"sv); } diff --git a/Tests/LibTLS/TestTLSHandshake.cpp b/Tests/LibTLS/TestTLSHandshake.cpp index d23c4e9b62b..06aec37fe4a 100644 --- a/Tests/LibTLS/TestTLSHandshake.cpp +++ b/Tests/LibTLS/TestTLSHandshake.cpp @@ -15,7 +15,7 @@ static char const* ca_certs_file = "./ca_certs.ini"; static int port = 443; -constexpr char const* DEFAULT_SERVER { "www.google.com" }; +constexpr auto DEFAULT_SERVER = "www.google.com"sv; static ByteBuffer operator""_b(char const* string, size_t length) { @@ -101,8 +101,8 @@ TEST_CASE(test_TLS_hello_handshake) return; } - auto* the_server = DEFAULT_SERVER; - if (!tls->write_or_error(StringView(the_server).bytes())) { + auto the_server = DEFAULT_SERVER; + if (!tls->write_or_error(the_server.bytes())) { FAIL("write(1) failed"); return; } diff --git a/Tests/LibTextCodec/TestTextDecoders.cpp b/Tests/LibTextCodec/TestTextDecoders.cpp index 6d51c3b1140..c5964695a61 100644 --- a/Tests/LibTextCodec/TestTextDecoders.cpp +++ b/Tests/LibTextCodec/TestTextDecoders.cpp @@ -12,7 +12,7 @@ TEST_CASE(test_utf8_decode) { auto decoder = TextCodec::UTF8Decoder(); // Bytes for U+1F600 GRINNING FACE - auto test_string = "\xf0\x9f\x98\x80"; + auto test_string = "\xf0\x9f\x98\x80"sv; Vector processed_code_points; decoder.process(test_string, [&](u32 code_point) { diff --git a/Tests/LibUnicode/TestUnicodeLocale.cpp b/Tests/LibUnicode/TestUnicodeLocale.cpp index ac4abda8f6c..b3fe6d73b4f 100644 --- a/Tests/LibUnicode/TestUnicodeLocale.cpp +++ b/Tests/LibUnicode/TestUnicodeLocale.cpp @@ -259,9 +259,9 @@ TEST_CASE(parse_unicode_locale_id_with_other_extension) fail("en-z-aaa-a"sv); fail("en-0-aaa-a"sv); - pass("en-z-aa", { 'z', "aa"sv }); - pass("en-z-aa-bbb", { 'z', "aa-bbb"sv }); - pass("en-z-aa-bbb-cccccccc", { 'z', "aa-bbb-cccccccc"sv }); + pass("en-z-aa"sv, { 'z', "aa"sv }); + pass("en-z-aa-bbb"sv, { 'z', "aa-bbb"sv }); + pass("en-z-aa-bbb-cccccccc"sv, { 'z', "aa-bbb-cccccccc"sv }); } TEST_CASE(parse_unicode_locale_id_with_private_use_extension) @@ -282,10 +282,10 @@ TEST_CASE(parse_unicode_locale_id_with_private_use_extension) fail("en-x-aaa-"sv); fail("en-x-aaa-aaaaaaaaa"sv); - pass("en-x-a", { "a"sv }); - pass("en-x-aaaaaaaa", { "aaaaaaaa"sv }); - pass("en-x-aaa-bbb", { "aaa"sv, "bbb"sv }); - pass("en-x-aaa-x-bbb", { "aaa"sv, "x"sv, "bbb"sv }); + pass("en-x-a"sv, { "a"sv }); + pass("en-x-aaaaaaaa"sv, { "aaaaaaaa"sv }); + pass("en-x-aaa-bbb"sv, { "aaa"sv, "bbb"sv }); + pass("en-x-aaa-x-bbb"sv, { "aaa"sv, "x"sv, "bbb"sv }); } TEST_CASE(canonicalize_unicode_locale_id) diff --git a/Tests/LibWeb/TestHTMLTokenizer.cpp b/Tests/LibWeb/TestHTMLTokenizer.cpp index f44e2fe12c7..e9ec810ca3e 100644 --- a/Tests/LibWeb/TestHTMLTokenizer.cpp +++ b/Tests/LibWeb/TestHTMLTokenizer.cpp @@ -42,9 +42,9 @@ using Token = Web::HTML::HTMLToken; EXPECT_EQ(current_token->code_point(), (u32)(character)); \ NEXT_TOKEN(); -#define EXPECT_CHARACTER_TOKENS(string) \ - for (auto c : StringView(#string)) { \ - EXPECT_CHARACTER_TOKEN(c); \ +#define EXPECT_CHARACTER_TOKENS(string) \ + for (auto c : #string##sv) { \ + EXPECT_CHARACTER_TOKEN(c); \ } #define EXPECT_COMMENT_TOKEN() \ @@ -87,7 +87,7 @@ static u32 hash_tokens(Vector const& tokens) TEST_CASE(empty) { - auto tokens = run_tokenizer(""); + auto tokens = run_tokenizer(""sv); BEGIN_ENUMERATION(tokens); EXPECT_END_OF_FILE_TOKEN(); END_ENUMERATION(); @@ -95,7 +95,7 @@ TEST_CASE(empty) TEST_CASE(basic) { - auto tokens = run_tokenizer(""); + auto tokens = run_tokenizer(""sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(html); EXPECT_START_TAG_TOKEN(head); @@ -109,7 +109,7 @@ TEST_CASE(basic) TEST_CASE(basic_with_text) { - auto tokens = run_tokenizer("

This is some text.

"); + auto tokens = run_tokenizer("

This is some text.

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_CHARACTER_TOKENS(This is some text.); @@ -120,7 +120,7 @@ TEST_CASE(basic_with_text) TEST_CASE(unquoted_attributes) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_TAG_TOKEN_ATTRIBUTE_COUNT(1); @@ -131,7 +131,7 @@ TEST_CASE(unquoted_attributes) TEST_CASE(single_quoted_attributes) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_TAG_TOKEN_ATTRIBUTE_COUNT(1); @@ -142,7 +142,7 @@ TEST_CASE(single_quoted_attributes) TEST_CASE(double_quoted_attributes) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_TAG_TOKEN_ATTRIBUTE_COUNT(1); @@ -153,7 +153,7 @@ TEST_CASE(double_quoted_attributes) TEST_CASE(multiple_attributes) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_TAG_TOKEN_ATTRIBUTE_COUNT(3); @@ -166,7 +166,7 @@ TEST_CASE(multiple_attributes) TEST_CASE(character_reference_in_attribute) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_TAG_TOKEN_ATTRIBUTE_COUNT(3); @@ -179,7 +179,7 @@ TEST_CASE(character_reference_in_attribute) TEST_CASE(comment) { - auto tokens = run_tokenizer("

"); + auto tokens = run_tokenizer("

"sv); BEGIN_ENUMERATION(tokens); EXPECT_START_TAG_TOKEN(p); EXPECT_COMMENT_TOKEN(); @@ -190,7 +190,7 @@ TEST_CASE(comment) TEST_CASE(doctype) { - auto tokens = run_tokenizer(""); + auto tokens = run_tokenizer(""sv); BEGIN_ENUMERATION(tokens); EXPECT_DOCTYPE_TOKEN(); EXPECT_START_TAG_TOKEN(html); @@ -201,7 +201,7 @@ TEST_CASE(doctype) // If that changes, or something is added to the test HTML, the hash needs to be adjusted. TEST_CASE(regression) { - auto file = MUST(Core::Stream::File::open("/usr/Tests/LibWeb/tokenizer-test.html", Core::Stream::OpenMode::Read)); + auto file = MUST(Core::Stream::File::open("/usr/Tests/LibWeb/tokenizer-test.html"sv, Core::Stream::OpenMode::Read)); auto file_size = MUST(file->size()); auto content = MUST(ByteBuffer::create_uninitialized(file_size)); MUST(file->read(content.bytes())); diff --git a/Tests/LibXML/TestParser.cpp b/Tests/LibXML/TestParser.cpp index 2110ba8d274..f763e9173ef 100644 --- a/Tests/LibXML/TestParser.cpp +++ b/Tests/LibXML/TestParser.cpp @@ -15,7 +15,7 @@ TEST_CASE(char_data_ending) // but it did _not_ consume it and would instead tell GenericLexer that it should stop consuming characters. Therefore, we only consumed 2 characters. // Then, it would see that we are in the state where we've seen the full `]]>` and try to take off three characters from the end of the consumed // input when we only have 2 characters, causing an assertion failure as we are asking to take off more characters than there really is. - XML::Parser parser("]]>"); + XML::Parser parser("]]>"sv); (void)parser.parse(); return Test::Crash::Failure::DidNotCrash; }); @@ -24,7 +24,7 @@ TEST_CASE(char_data_ending) TEST_CASE(character_reference_integer_overflow) { EXPECT_NO_CRASH("parsing character references that do not fit in 32 bits should not crash", [] { - XML::Parser parser("�"); + XML::Parser parser("�"sv); (void)parser.parse(); return Test::Crash::Failure::DidNotCrash; }); diff --git a/Tests/Spreadsheet/test-spreadsheet.cpp b/Tests/Spreadsheet/test-spreadsheet.cpp index 425aedac182..838164ae5eb 100644 --- a/Tests/Spreadsheet/test-spreadsheet.cpp +++ b/Tests/Spreadsheet/test-spreadsheet.cpp @@ -38,7 +38,7 @@ TESTJS_RUN_FILE_FUNCTION(String const&, JS::Interpreter& interpreter, JS::Execut run_file(LexicalPath::join(Test::JS::g_test_root, s_spreadsheet_runtime_path).string()); #endif - run_file("mock.test-common.js"); + run_file("mock.test-common.js"sv); return Test::JS::RunFileHookResult::RunAsNormal; } diff --git a/Userland/Applets/Audio/main.cpp b/Userland/Applets/Audio/main.cpp index 586c5ca929d..58c01aa1561 100644 --- a/Userland/Applets/Audio/main.cpp +++ b/Userland/Applets/Audio/main.cpp @@ -37,11 +37,11 @@ public: static ErrorOr> try_create() { Array volume_level_bitmaps = { - { { 66, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-high.png")) }, - { 33, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-medium.png")) }, - { 1, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-low.png")) }, - { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png")) }, - { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png")) } } + { { 66, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-high.png"sv)) }, + { 33, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-medium.png"sv)) }, + { 1, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-low.png"sv)) }, + { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-zero.png"sv)) }, + { 0, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/audio-volume-muted.png"sv)) } } }; auto audio_client = TRY(Audio::ConnectionFromClient::try_create()); NonnullRefPtr audio_widget = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) AudioWidget(move(audio_client), move(volume_level_bitmaps)))); @@ -53,7 +53,7 @@ private: AudioWidget(NonnullRefPtr audio_client, Array volume_level_bitmaps) : m_audio_client(move(audio_client)) , m_volume_level_bitmaps(move(volume_level_bitmaps)) - , m_show_percent(Config::read_bool("AudioApplet", "Applet", "ShowPercent", false)) + , m_show_percent(Config::read_bool("AudioApplet"sv, "Applet"sv, "ShowPercent"sv, false)) { m_audio_volume = static_cast(m_audio_client->get_main_mix_volume() * 100); m_audio_muted = m_audio_client->is_main_mix_muted(); @@ -102,7 +102,7 @@ private: m_percent_box->set_tooltip(m_show_percent ? "Hide percent" : "Show percent"); GUI::Application::the()->hide_tooltip(); - Config::write_bool("AudioApplet", "Applet", "ShowPercent", m_show_percent); + Config::write_bool("AudioApplet"sv, "Applet"sv, "ShowPercent"sv, m_show_percent); }; m_slider = m_root_container->add(); @@ -254,7 +254,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->show(); // This positioning code depends on the window actually existing. - static_cast(window->main_widget())->set_audio_widget_size(Config::read_bool("AudioApplet", "Applet", "ShowPercent", false)); + static_cast(window->main_widget())->set_audio_widget_size(Config::read_bool("AudioApplet"sv, "Applet"sv, "ShowPercent"sv, false)); TRY(Core::System::pledge("stdio recvfd sendfd rpath")); diff --git a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp index 40f90c18b53..99806f9a416 100644 --- a/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp +++ b/Userland/Applets/ClipboardHistory/ClipboardHistoryModel.cpp @@ -17,7 +17,7 @@ NonnullRefPtr ClipboardHistoryModel::create() } ClipboardHistoryModel::ClipboardHistoryModel() - : m_history_limit(Config::read_i32("ClipboardHistory", "ClipboardHistory", "NumHistoryItems", 20)) + : m_history_limit(Config::read_i32("ClipboardHistory"sv, "ClipboardHistory"sv, "NumHistoryItems"sv, 20)) { } @@ -37,26 +37,26 @@ String ClipboardHistoryModel::column_name(int column) const } } -static char const* bpp_for_format_resilient(String format) +static StringView bpp_for_format_resilient(String format) { unsigned format_uint = format.to_uint().value_or(static_cast(Gfx::BitmapFormat::Invalid)); // Cannot use Gfx::Bitmap::bpp_for_format here, as we have to accept invalid enum values. switch (static_cast(format_uint)) { case Gfx::BitmapFormat::Indexed1: - return "1"; + return "1"sv; case Gfx::BitmapFormat::Indexed2: - return "2"; + return "2"sv; case Gfx::BitmapFormat::Indexed4: - return "4"; + return "4"sv; case Gfx::BitmapFormat::Indexed8: - return "8"; + return "8"sv; case Gfx::BitmapFormat::BGRx8888: case Gfx::BitmapFormat::BGRA8888: - return "32"; + return "32"sv; case Gfx::BitmapFormat::Invalid: /* fall-through */ default: - return "?"; + return "?"sv; } } @@ -69,7 +69,7 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode auto& time = item.time; switch (index.column()) { case Column::Data: - if (data_and_type.mime_type.starts_with("text/")) + if (data_and_type.mime_type.starts_with("text/"sv)) return String::copy(data_and_type.data); if (data_and_type.mime_type == "image/x-serenityos") { StringBuilder builder; @@ -79,11 +79,11 @@ GUI::Variant ClipboardHistoryModel::data(const GUI::ModelIndex& index, GUI::Mode builder.append(data_and_type.metadata.get("height").value_or("?")); builder.append('x'); builder.append(bpp_for_format_resilient(data_and_type.metadata.get("format").value_or("0"))); - builder.append(" bitmap"); builder.append("]"); + builder.append(" bitmap"sv); return builder.to_string(); } - if (data_and_type.mime_type.starts_with("glyph/")) { + if (data_and_type.mime_type.starts_with("glyph/"sv)) { StringBuilder builder; auto count = data_and_type.metadata.get("count").value().to_uint().value_or(0); auto start = data_and_type.metadata.get("start").value().to_uint().value_or(0); diff --git a/Userland/Applets/ClipboardHistory/main.cpp b/Userland/Applets/ClipboardHistory/main.cpp index f3e705ae354..0902ccb8c2f 100644 --- a/Userland/Applets/ClipboardHistory/main.cpp +++ b/Userland/Applets/ClipboardHistory/main.cpp @@ -26,7 +26,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath")); TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("edit-copy")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("edit-copy"sv)); auto main_window = TRY(GUI::Window::try_create()); main_window->set_title("Clipboard history"); @@ -67,7 +67,7 @@ ErrorOr serenity_main(Main::Arguments arguments) applet_window->set_has_alpha_channel(true); auto icon_widget = TRY(applet_window->try_set_main_widget()); icon_widget->set_tooltip("Clipboard History"); - icon_widget->load_from_file("/res/icons/16x16/edit-copy.png"); + icon_widget->load_from_file("/res/icons/16x16/edit-copy.png"sv); icon_widget->on_click = [&main_window = *main_window] { main_window.show(); main_window.move_to_front(); diff --git a/Userland/Applets/Keymap/KeymapStatusWindow.cpp b/Userland/Applets/Keymap/KeymapStatusWindow.cpp index 873a4ad4684..a0e42759c91 100644 --- a/Userland/Applets/Keymap/KeymapStatusWindow.cpp +++ b/Userland/Applets/Keymap/KeymapStatusWindow.cpp @@ -16,7 +16,7 @@ void KeymapStatusWidget::mousedown_event(GUI::MouseEvent& event) if (event.button() != GUI::MouseButton::Primary) return; - GUI::Process::spawn_or_show_error(window(), "/bin/KeyboardSettings"); + GUI::Process::spawn_or_show_error(window(), "/bin/KeyboardSettings"sv); } KeymapStatusWindow::KeymapStatusWindow() diff --git a/Userland/Applets/Network/main.cpp b/Userland/Applets/Network/main.cpp index 51d2b53bbae..25d3466faaa 100644 --- a/Userland/Applets/Network/main.cpp +++ b/Userland/Applets/Network/main.cpp @@ -26,8 +26,8 @@ class NetworkWidget final : public GUI::ImageWidget { public: static ErrorOr> try_create(bool notifications) { - NonnullRefPtr connected_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network.png")); - NonnullRefPtr disconnected_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png")); + NonnullRefPtr connected_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network.png"sv)); + NonnullRefPtr disconnected_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png"sv)); return adopt_nonnull_ref_or_enomem(new (nothrow) NetworkWidget(notifications, move(connected_icon), move(disconnected_icon))); } @@ -50,7 +50,7 @@ private: { if (event.button() != GUI::MouseButton::Primary) return; - GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor", Array { "-t", "network" }); + GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor"sv, Array { "-t", "network" }); } virtual void update_widget() @@ -124,10 +124,10 @@ private: int connected_adapters = 0; json.value().as_array().for_each([&adapter_info, include_loopback, &connected_adapters](auto& value) { auto& if_object = value.as_object(); - auto ip_address = if_object.get("ipv4_address").as_string_or("no IP"); - auto ifname = if_object.get("name").to_string(); - auto link_up = if_object.get("link_up").as_bool(); - auto link_speed = if_object.get("link_speed").to_i32(); + auto ip_address = if_object.get("ipv4_address"sv).as_string_or("no IP"); + auto ifname = if_object.get("name"sv).to_string(); + auto link_up = if_object.get("link_up"sv).as_bool(); + auto link_speed = if_object.get("link_speed"sv).to_i32(); if (!include_loopback) if (ifname == "loop") @@ -185,7 +185,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_has_alpha_channel(true); window->resize(16, 16); auto icon = TRY(window->try_set_main_widget(display_notifications)); - icon->load_from_file("/res/icons/16x16/network.png"); + icon->load_from_file("/res/icons/16x16/network.png"sv); window->resize(16, 16); window->show(); diff --git a/Userland/Applets/ResourceGraph/main.cpp b/Userland/Applets/ResourceGraph/main.cpp index 5dbc5f389f4..c506c26fb01 100644 --- a/Userland/Applets/ResourceGraph/main.cpp +++ b/Userland/Applets/ResourceGraph/main.cpp @@ -58,7 +58,7 @@ private: m_tooltip = String::formatted("CPU usage: {:.1}%", 100 * cpu); } else { m_history.enqueue(-1); - m_tooltip = StringView("Unable to determine CPU usage"); + m_tooltip = "Unable to determine CPU usage"sv; } break; } @@ -71,7 +71,7 @@ private: m_tooltip = String::formatted("Memory: {} MiB of {:.1} MiB in use", allocated / MiB, total_memory / MiB); } else { m_history.enqueue(-1); - m_tooltip = StringView("Unable to determine memory usage"); + m_tooltip = "Unable to determine memory usage"sv; } break; } @@ -102,7 +102,7 @@ private: m_tooltip = String::formatted("Network: TX {} / RX {} ({:.1} kbit/s)", tx, rx, static_cast(recent_tx) * 8.0 / 1000.0); } else { m_history.enqueue(-1); - m_tooltip = StringView("Unable to determine network usage"); + m_tooltip = "Unable to determine network usage"sv; } break; } @@ -142,7 +142,7 @@ private: { if (event.button() != GUI::MouseButton::Primary) return; - GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor", Array { "-t", m_graph_type == GraphType::Network ? "network" : "graphs" }); + GUI::Process::spawn_or_show_error(window(), "/bin/SystemMonitor"sv, Array { "-t", m_graph_type == GraphType::Network ? "network" : "graphs" }); } bool get_cpu_usage(u64& total, u64& idle) @@ -167,8 +167,8 @@ private: return false; auto json = json_or_error.release_value(); auto const& obj = json.as_object(); - total = obj.get("total_time").to_u64(); - idle = obj.get("idle_time").to_u64(); + total = obj.get("total_time"sv).to_u64(); + idle = obj.get("idle_time"sv).to_u64(); return true; } @@ -191,11 +191,11 @@ private: return false; auto json = json_or_error.release_value(); auto const& obj = json.as_object(); - unsigned kmalloc_allocated = obj.get("kmalloc_allocated").to_u32(); - unsigned kmalloc_available = obj.get("kmalloc_available").to_u32(); - auto user_physical_allocated = obj.get("user_physical_allocated").to_u64(); - auto user_physical_committed = obj.get("user_physical_committed").to_u64(); - auto user_physical_uncommitted = obj.get("user_physical_uncommitted").to_u64(); + unsigned kmalloc_allocated = obj.get("kmalloc_allocated"sv).to_u32(); + unsigned kmalloc_available = obj.get("kmalloc_available"sv).to_u32(); + auto user_physical_allocated = obj.get("user_physical_allocated"sv).to_u64(); + auto user_physical_committed = obj.get("user_physical_committed"sv).to_u64(); + auto user_physical_uncommitted = obj.get("user_physical_uncommitted"sv).to_u64(); unsigned kmalloc_bytes_total = kmalloc_allocated + kmalloc_available; unsigned kmalloc_pages_total = (kmalloc_bytes_total + PAGE_SIZE - 1) / PAGE_SIZE; u64 total_userphysical_and_swappable_pages = kmalloc_pages_total + user_physical_allocated + user_physical_committed + user_physical_uncommitted; @@ -226,13 +226,13 @@ private: auto const& array = json.as_array(); for (auto const& adapter_value : array.values()) { auto const& adapter_obj = adapter_value.as_object(); - if (!adapter_obj.has_string("ipv4_address") || !adapter_obj.get("link_up").as_bool()) + if (!adapter_obj.has_string("ipv4_address"sv) || !adapter_obj.get("link_up"sv).as_bool()) continue; - tx += adapter_obj.get("bytes_in").to_u64(); - rx += adapter_obj.get("bytes_out").to_u64(); + tx += adapter_obj.get("bytes_in"sv).to_u64(); + rx += adapter_obj.get("bytes_out"sv).to_u64(); // Link speed data is given in megabits, but we want all return values to be in bytes. - link_speed += adapter_obj.get("link_speed").to_u64() * 8'000'000; + link_speed += adapter_obj.get("link_speed"sv).to_u64() * 8'000'000; } link_speed /= 8; return tx != 0; diff --git a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp index 2ccecbb5757..167a8992857 100644 --- a/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp +++ b/Userland/Applications/3DFileViewer/WavefrontOBJLoader.cpp @@ -31,7 +31,7 @@ RefPtr WavefrontOBJLoader::load(Core::File& file) if (object_line.starts_with("#")) continue; - if (object_line.starts_with("vt")) { + if (object_line.starts_with("vt"sv)) { auto tex_coord_line = object_line.split_view(' '); if (tex_coord_line.size() != 3) { dbgln("Wavefront: Malformed TexCoord line. Aborting."); @@ -44,7 +44,7 @@ RefPtr WavefrontOBJLoader::load(Core::File& file) continue; } - if (object_line.starts_with("vn")) { + if (object_line.starts_with("vn"sv)) { auto normal_line = object_line.split_view(' '); if (normal_line.size() != 4) { dbgln("Wavefront: Malformed vertex normal line. Aborting."); diff --git a/Userland/Applications/3DFileViewer/main.cpp b/Userland/Applications/3DFileViewer/main.cpp index f4a2475c1e2..49b0a7babb3 100644 --- a/Userland/Applications/3DFileViewer/main.cpp +++ b/Userland/Applications/3DFileViewer/main.cpp @@ -284,7 +284,7 @@ bool GLContextWidget::load_path(String const& filename) auto file = Core::File::construct(filename); if (!file->open(Core::OpenMode::ReadOnly) && file->error() != ENOENT) { - GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: {}", filename, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -294,31 +294,31 @@ bool GLContextWidget::load_path(String const& filename) bool GLContextWidget::load_file(Core::File& file) { auto const& filename = file.filename(); - if (!filename.ends_with(".obj")) { - GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: invalid file type", filename), "Error", GUI::MessageBox::Type::Error); + if (!filename.ends_with(".obj"sv)) { + GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: invalid file type", filename), "Error"sv, GUI::MessageBox::Type::Error); return false; } if (file.is_device()) { - GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open device files", filename), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open device files", filename), "Error"sv, GUI::MessageBox::Type::Error); return false; } if (file.is_directory()) { - GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", filename), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Opening \"{}\" failed: Can't open directories", filename), "Error"sv, GUI::MessageBox::Type::Error); return false; } auto new_mesh = m_mesh_loader->load(file); if (new_mesh.is_null()) { - GUI::MessageBox::show(window(), String::formatted("Reading \"{}\" failed.", filename), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Reading \"{}\" failed.", filename), "Error"sv, GUI::MessageBox::Type::Error); return false; } // Determine whether or not a texture for this model resides within the same directory StringBuilder builder; builder.append(filename.split('.').at(0)); - builder.append(".bmp"); + builder.append(".bmp"sv); String texture_path = Core::File::absolute_path(builder.string_view()); @@ -368,7 +368,7 @@ ErrorOr serenity_main(Main::Arguments arguments) // Construct the main window auto window = GUI::Window::construct(); - auto app_icon = GUI::Icon::default_icon("app-3d-file-viewer"); + auto app_icon = GUI::Icon::default_icon("app-3d-file-viewer"sv); window->set_icon(app_icon.bitmap_for_size(16)); window->set_title("3D File Viewer"); window->resize(640 + 4, 480 + 4); diff --git a/Userland/Applications/About/main.cpp b/Userland/Applications/About/main.cpp index 3065a2143ea..0cc6a5949c7 100644 --- a/Userland/Applications/About/main.cpp +++ b/Userland/Applications/About/main.cpp @@ -20,7 +20,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("ladyball")); - GUI::AboutDialog::show("SerenityOS", app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16), Core::Version::read_long_version_string()); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("ladyball"sv)); + GUI::AboutDialog::show("SerenityOS"sv, app_icon.bitmap_for_size(32), nullptr, app_icon.bitmap_for_size(16), Core::Version::read_long_version_string()); return app->exec(); } diff --git a/Userland/Applications/AnalogClock/AnalogClock.cpp b/Userland/Applications/AnalogClock/AnalogClock.cpp index 747cf20f94c..b5d95fb33b1 100644 --- a/Userland/Applications/AnalogClock/AnalogClock.cpp +++ b/Userland/Applications/AnalogClock/AnalogClock.cpp @@ -130,7 +130,7 @@ void AnalogClock::paint_event(GUI::PaintEvent& event) void AnalogClock::update_title_date() { - window()->set_title(Core::DateTime::now().to_string("%Y-%m-%d")); + window()->set_title(Core::DateTime::now().to_string("%Y-%m-%d"sv)); } void AnalogClock::context_menu_event(GUI::ContextMenuEvent& event) diff --git a/Userland/Applications/AnalogClock/main.cpp b/Userland/Applications/AnalogClock/main.cpp index 719103410e8..118d056d322 100644 --- a/Userland/Applications/AnalogClock/main.cpp +++ b/Userland/Applications/AnalogClock/main.cpp @@ -24,9 +24,9 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-analog-clock")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-analog-clock"sv)); auto window = TRY(GUI::Window::try_create()); - window->set_title(Core::DateTime::now().to_string("%Y-%m-%d")); + window->set_title(Core::DateTime::now().to_string("%Y-%m-%d"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->resize(170, 170); window->set_resizable(false); diff --git a/Userland/Applications/Assistant/Providers.cpp b/Userland/Applications/Assistant/Providers.cpp index 933fc0d0054..adb65e86d7c 100644 --- a/Userland/Applications/Assistant/Providers.cpp +++ b/Userland/Applications/Assistant/Providers.cpp @@ -52,7 +52,7 @@ void TerminalResult::activate() const // FIXME: This should be a GUI::Process::spawn_or_show_error(), however this is a // Assistant::Result object, which does not have access to the application's GUI::Window* pointer // (which spawn_or_show_error() needs incase it has to open a error message box). - (void)Core::Process::spawn("/bin/Terminal", Array { "-k", "-e", title().characters() }); + (void)Core::Process::spawn("/bin/Terminal"sv, Array { "-k", "-e", title().characters() }); } void URLResult::activate() const diff --git a/Userland/Applications/Assistant/Providers.h b/Userland/Applications/Assistant/Providers.h index b240e18e537..f9aed966486 100644 --- a/Userland/Applications/Assistant/Providers.h +++ b/Userland/Applications/Assistant/Providers.h @@ -72,7 +72,7 @@ class CalculatorResult final : public Result { public: explicit CalculatorResult(String title) : Result(move(title), "'Enter' will copy to clipboard"sv, 100) - , m_bitmap(GUI::Icon::default_icon("app-calculator").bitmap_for_size(16)) + , m_bitmap(GUI::Icon::default_icon("app-calculator"sv).bitmap_for_size(16)) { } ~CalculatorResult() override = default; @@ -100,7 +100,7 @@ class TerminalResult final : public Result { public: explicit TerminalResult(String command) : Result(move(command), "Run command in Terminal"sv, 100) - , m_bitmap(GUI::Icon::default_icon("app-terminal").bitmap_for_size(16)) + , m_bitmap(GUI::Icon::default_icon("app-terminal"sv).bitmap_for_size(16)) { } ~TerminalResult() override = default; @@ -116,7 +116,7 @@ class URLResult final : public Result { public: explicit URLResult(const URL& url) : Result(url.to_string(), "'Enter' will open this URL in the browser"sv, 50) - , m_bitmap(GUI::Icon::default_icon("app-browser").bitmap_for_size(16)) + , m_bitmap(GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16)) { } ~URLResult() override = default; diff --git a/Userland/Applications/Browser/BrowserWindow.cpp b/Userland/Applications/Browser/BrowserWindow.cpp index bc2b96ca284..0753f441779 100644 --- a/Userland/Applications/Browser/BrowserWindow.cpp +++ b/Userland/Applications/Browser/BrowserWindow.cpp @@ -45,7 +45,7 @@ static String bookmarks_file_path() { StringBuilder builder; builder.append(Core::StandardPaths::config_directory()); - builder.append("/bookmarks.json"); + builder.append("/bookmarks.json"sv); return builder.to_string(); } @@ -53,7 +53,7 @@ static String search_engines_file_path() { StringBuilder builder; builder.append(Core::StandardPaths::config_directory()); - builder.append("/SearchEngines.json"); + builder.append("/SearchEngines.json"sv); return builder.to_string(); } @@ -61,7 +61,7 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url) : m_cookie_jar(cookie_jar) , m_window_actions(*this) { - auto app_icon = GUI::Icon::default_icon("app-browser"); + auto app_icon = GUI::Icon::default_icon("app-browser"sv); m_bookmarks_bar = Browser::BookmarksBarWidget::construct(Browser::bookmarks_file_path(), true); resize(730, 560); @@ -123,25 +123,25 @@ BrowserWindow::BrowserWindow(CookieJar& cookie_jar, URL url) }); m_window_actions.on_about = [this] { - auto app_icon = GUI::Icon::default_icon("app-browser"); - GUI::AboutDialog::show("Browser", app_icon.bitmap_for_size(32), this); + auto app_icon = GUI::Icon::default_icon("app-browser"sv); + GUI::AboutDialog::show("Browser"sv, app_icon.bitmap_for_size(32), this); }; m_window_actions.on_show_bookmarks_bar = [](auto& action) { Browser::BookmarksBarWidget::the().set_visible(action.is_checked()); - Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", action.is_checked()); + Config::write_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, action.is_checked()); }; - bool show_bookmarks_bar = Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", true); + bool show_bookmarks_bar = Config::read_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, true); m_window_actions.show_bookmarks_bar_action().set_checked(show_bookmarks_bar); Browser::BookmarksBarWidget::the().set_visible(show_bookmarks_bar); m_window_actions.on_vertical_tabs = [this](auto& action) { m_tab_widget->set_tab_position(action.is_checked() ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top); - Config::write_bool("Browser", "Preferences", "VerticalTabs", action.is_checked()); + Config::write_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, action.is_checked()); }; - bool vertical_tabs = Config::read_bool("Browser", "Preferences", "VerticalTabs", false); + bool vertical_tabs = Config::read_bool("Browser"sv, "Preferences"sv, "VerticalTabs"sv, false); m_window_actions.vertical_tabs_action().set_checked(vertical_tabs); m_tab_widget->set_tab_position(vertical_tabs ? GUI::TabWidget::TabPosition::Left : GUI::TabWidget::TabPosition::Top); @@ -258,13 +258,13 @@ void BrowserWindow::build_menus() m_change_homepage_action = GUI::Action::create( "Set Homepage URL...", g_icon_bag.go_home, [this](auto&) { - auto homepage_url = Config::read_string("Browser", "Preferences", "Home", "about:blank"); - if (GUI::InputBox::show(this, homepage_url, "Enter URL", "Change homepage URL") == GUI::InputBox::ExecResult::OK) { + auto homepage_url = Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, "about:blank"sv); + if (GUI::InputBox::show(this, homepage_url, "Enter URL"sv, "Change homepage URL"sv) == GUI::InputBox::ExecResult::OK) { if (URL(homepage_url).is_valid()) { - Config::write_string("Browser", "Preferences", "Home", homepage_url); + Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url); Browser::g_home_url = homepage_url; } else { - GUI::MessageBox::show_error(this, "The URL you have entered is not valid"); + GUI::MessageBox::show_error(this, "The URL you have entered is not valid"sv); } } }, @@ -280,13 +280,13 @@ void BrowserWindow::build_menus() auto& color_scheme_menu = settings_menu.add_submenu("&Color Scheme"); color_scheme_menu.set_icon(g_icon_bag.color_chooser); { - auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser", "Preferences", "ColorScheme", "auto")); + auto current_setting = Web::CSS::preferred_color_scheme_from_string(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, "auto"sv)); m_color_scheme_actions.set_exclusive(true); auto add_color_scheme_action = [&](auto& name, Web::CSS::PreferredColorScheme preference_value) { auto action = GUI::Action::create_checkable( name, [=, this](auto&) { - Config::write_string("Browser", "Preferences", "ColorScheme", Web::CSS::preferred_color_scheme_to_string(preference_value)); + Config::write_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, Web::CSS::preferred_color_scheme_to_string(preference_value)); active_tab().view().set_preferred_color_scheme(preference_value); }, this); @@ -302,9 +302,9 @@ void BrowserWindow::build_menus() } settings_menu.add_separator(); - auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value_but_fixme_should_propagate_errors(), + auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { - GUI::Process::spawn_or_show_error(this, "/bin/BrowserSettings"); + GUI::Process::spawn_or_show_error(this, "/bin/BrowserSettings"sv); }); settings_menu.add_action(move(open_settings_action)); @@ -385,7 +385,7 @@ void BrowserWindow::build_menus() auto custom_user_agent = GUI::Action::create_checkable("Custom...", [this](auto& action) { String user_agent; - if (GUI::InputBox::show(this, user_agent, "Enter User Agent:", "Custom User Agent") != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) { + if (GUI::InputBox::show(this, user_agent, "Enter User Agent:"sv, "Custom User Agent"sv) != GUI::InputBox::ExecResult::OK || user_agent.is_empty() || user_agent.is_null()) { m_disable_user_agent_spoofing->activate(); return; } @@ -426,7 +426,7 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) m_disable_search_engine_action = GUI::Action::create_checkable( "Disable", [](auto&) { g_search_engine = {}; - Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine); }, this); search_engine_menu.add_action(*m_disable_search_engine_action); @@ -444,13 +444,13 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) if (!json_item.is_object()) continue; auto search_engine = json_item.as_object(); - auto name = search_engine.get("title").to_string(); - auto url_format = search_engine.get("url_format").to_string(); + auto name = search_engine.get("title"sv).to_string(); + auto url_format = search_engine.get("url_format"sv).to_string(); auto action = GUI::Action::create_checkable( name, [&, url_format](auto&) { g_search_engine = url_format; - Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine); }, this); search_engine_menu.add_action(action); @@ -467,20 +467,20 @@ ErrorOr BrowserWindow::load_search_engines(GUI::Menu& settings_menu) auto custom_search_engine_action = GUI::Action::create_checkable("Custom...", [&](auto& action) { String search_engine; - if (GUI::InputBox::show(this, search_engine, "Enter URL template:", "Custom Search Engine", "https://host/search?q={}") != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) { + if (GUI::InputBox::show(this, search_engine, "Enter URL template:"sv, "Custom Search Engine"sv, "https://host/search?q={}"sv) != GUI::InputBox::ExecResult::OK || search_engine.is_empty()) { m_disable_search_engine_action->activate(); return; } auto argument_count = search_engine.count("{}"sv); if (argument_count != 1) { - GUI::MessageBox::show(this, "Invalid format, must contain '{}' once!", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, "Invalid format, must contain '{}' once!"sv, "Error"sv, GUI::MessageBox::Type::Error); m_disable_search_engine_action->activate(); return; } g_search_engine = search_engine; - Config::write_string("Browser", "Preferences", "SearchEngine", g_search_engine); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, g_search_engine); action.set_status_tip(search_engine); }); search_engine_menu.add_action(custom_search_engine_action); @@ -608,7 +608,7 @@ void BrowserWindow::config_string_did_change(String const& domain, String const& Browser::g_home_url = value; else if (key == "NewTab") Browser::g_new_tab_url = value; - } else if (group.starts_with("Proxy:")) { + } else if (group.starts_with("Proxy:"sv)) { dbgln("Proxy mapping changed: {}/{} = {}", group, key, value); auto proxy_spec = group.substring_view(6); auto existing_proxy = Browser::g_proxies.find(proxy_spec); diff --git a/Userland/Applications/Browser/ConsoleWidget.cpp b/Userland/Applications/Browser/ConsoleWidget.cpp index 3603e856bb4..392c4d6f611 100644 --- a/Userland/Applications/Browser/ConsoleWidget.cpp +++ b/Userland/Applications/Browser/ConsoleWidget.cpp @@ -25,7 +25,7 @@ ConsoleWidget::ConsoleWidget() set_fill_with_background_color(true); m_output_view = add(); - m_output_view->load("data:text/html,"); + m_output_view->load("data:text/html,"sv); // Wait until our output WebView is loaded, and then request any messages that occurred before we existed m_output_view->on_load_finish = [this](auto&) { if (on_request_messages) @@ -130,9 +130,9 @@ void ConsoleWidget::handle_console_messages(i32 start_index, Vector cons void ConsoleWidget::print_source_line(StringView source) { StringBuilder html; - html.append(""); - html.append("> "); - html.append(""); + html.append(""sv); + html.append("> "sv); + html.append(""sv); html.append(JS::MarkupGenerator::html_from_source(source)); @@ -147,7 +147,7 @@ void ConsoleWidget::print_html(StringView line) if (parent_id == 0) { builder.append(R"~~~( var parentGroup = document.body; -)~~~"); +)~~~"sv); } else { builder.appendff(R"~~~( var parentGroup = document.getElementById("group_{}"); @@ -157,11 +157,11 @@ void ConsoleWidget::print_html(StringView line) builder.append(R"~~~( var p = document.createElement("p"); - p.innerHTML = ")~~~"); + p.innerHTML = ")~~~"sv); builder.append_escaped_for_json(line); builder.append(R"~~~(" parentGroup.appendChild(p); -)~~~"); +)~~~"sv); m_output_view->run_javascript(builder.string_view()); // FIXME: Make it scroll to the bottom, using `window.scrollTo()` in the JS above. // We used to call `m_output_view->scroll_to_bottom();` here, but that does not work because @@ -174,7 +174,7 @@ void ConsoleWidget::clear_output() m_group_stack.clear(); m_output_view->run_javascript(R"~~~( document.body.innerHTML = ""; - )~~~"); + )~~~"sv); } void ConsoleWidget::begin_group(StringView label, bool start_expanded) @@ -184,7 +184,7 @@ void ConsoleWidget::begin_group(StringView label, bool start_expanded) if (parent_id == 0) { builder.append(R"~~~( var parentGroup = document.body; -)~~~"); +)~~~"sv); } else { builder.appendff(R"~~~( var parentGroup = document.getElementById("group_{}"); @@ -206,10 +206,10 @@ void ConsoleWidget::begin_group(StringView label, bool start_expanded) builder.append(R"~~~("; group.appendChild(label); parentGroup.appendChild(group); -)~~~"); +)~~~"sv); if (start_expanded) - builder.append("group.open = true;"); + builder.append("group.open = true;"sv); m_output_view->run_javascript(builder.string_view()); // FIXME: Scroll console to bottom - see note in print_html() diff --git a/Userland/Applications/Browser/CookieJar.cpp b/Userland/Applications/Browser/CookieJar.cpp index d8be5e30e6f..fb97ad2e81e 100644 --- a/Userland/Applications/Browser/CookieJar.cpp +++ b/Userland/Applications/Browser/CookieJar.cpp @@ -29,7 +29,7 @@ String CookieJar::get_cookie(const URL& url, Web::Cookie::Source source) for (auto const& cookie : cookie_list) { // If there is an unprocessed cookie in the cookie-list, output the characters %x3B and %x20 ("; ") if (!builder.is_empty()) - builder.append("; "); + builder.append("; "sv); // Output the cookie's name, the %x3D ("=") character, and the cookie's value. builder.appendff("{}={}", cookie.name, cookie.value); @@ -50,9 +50,9 @@ void CookieJar::set_cookie(const URL& url, Web::Cookie::ParsedCookie const& pars void CookieJar::dump_cookies() const { - constexpr StringView key_color = "\033[34;1m"; - constexpr StringView attribute_color = "\033[33m"; - constexpr StringView no_color = "\033[0m"; + constexpr auto key_color = "\033[34;1m"sv; + constexpr auto attribute_color = "\033[33m"sv; + constexpr auto no_color = "\033[0m"sv; StringBuilder builder; builder.appendff("{} cookies stored\n", m_cookies.size()); diff --git a/Userland/Applications/Browser/DownloadWidget.cpp b/Userland/Applications/Browser/DownloadWidget.cpp index cfc6df68dda..50dfe3932b2 100644 --- a/Userland/Applications/Browser/DownloadWidget.cpp +++ b/Userland/Applications/Browser/DownloadWidget.cpp @@ -37,7 +37,7 @@ DownloadWidget::DownloadWidget(const URL& url) m_destination_path = builder.to_string(); } - auto close_on_finish = Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", false); + auto close_on_finish = Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, false); m_elapsed_timer.start(); m_download = Web::ResourceLoader::the().connector().start_request("GET", url); @@ -49,7 +49,7 @@ DownloadWidget::DownloadWidget(const URL& url) { auto file_or_error = Core::Stream::File::open(m_destination_path, Core::Stream::OpenMode::Write); if (file_or_error.is_error()) { - GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Cannot open {} for writing", m_destination_path), "Download failed"sv, GUI::MessageBox::Type::Error); window()->close(); return; } @@ -68,7 +68,7 @@ DownloadWidget::DownloadWidget(const URL& url) auto& animation_layout = animation_container.set_layout(); m_browser_image = animation_container.add(); - m_browser_image->load_from_file("/res/graphics/download-animation.gif"); + m_browser_image->load_from_file("/res/graphics/download-animation.gif"sv); animation_layout.add_spacer(); auto& source_label = add(String::formatted("From: {}", url)); @@ -90,7 +90,7 @@ DownloadWidget::DownloadWidget(const URL& url) m_close_on_finish_checkbox->set_checked(close_on_finish); m_close_on_finish_checkbox->on_checked = [&](bool checked) { - Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", checked); + Config::write_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, checked); }; auto& button_container = add(); @@ -126,7 +126,7 @@ void DownloadWidget::did_progress(Optional total_size, u32 downloaded_size) { StringBuilder builder; - builder.append("Downloaded "); + builder.append("Downloaded "sv); builder.append(human_readable_size(downloaded_size)); builder.appendff(" in {} sec", m_elapsed_timer.elapsed() / 1000); m_progress_label->set_text(builder.to_string()); @@ -140,7 +140,7 @@ void DownloadWidget::did_progress(Optional total_size, u32 downloaded_size) } else { builder.append(human_readable_size(downloaded_size)); } - builder.append(" of "); + builder.append(" of "sv); builder.append(m_url.basename()); window()->set_title(builder.to_string()); } @@ -150,7 +150,7 @@ void DownloadWidget::did_finish(bool success) { dbgln("did_finish, success={}", success); - m_browser_image->load_from_file("/res/graphics/download-finished.gif"); + m_browser_image->load_from_file("/res/graphics/download-finished.gif"sv); window()->set_title("Download finished!"); m_close_button->set_enabled(true); m_cancel_button->set_text("Open in Folder"); @@ -161,7 +161,7 @@ void DownloadWidget::did_finish(bool success) m_cancel_button->update(); if (!success) { - GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Download failed for some reason"), "Download failed"sv, GUI::MessageBox::Type::Error); window()->close(); return; } diff --git a/Userland/Applications/Browser/ElementSizePreviewWidget.cpp b/Userland/Applications/Browser/ElementSizePreviewWidget.cpp index a60f37a472e..0ee3e8aef65 100644 --- a/Userland/Applications/Browser/ElementSizePreviewWidget.cpp +++ b/Userland/Applications/Browser/ElementSizePreviewWidget.cpp @@ -83,7 +83,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event) draw_borders(margin_rect, Color::Black); margin_rect.shrink(1, 1, 1, 1); margin_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding); - painter.draw_text(margin_rect, "margin", font(), Gfx::TextAlignment::TopLeft, Color::Black); + painter.draw_text(margin_rect, "margin"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black); draw_size_texts(margin_rect, Color::Black, m_node_box_sizing.margin); // paint border box @@ -91,7 +91,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event) draw_borders(border_rect, Color::Black); border_rect.shrink(1, 1, 1, 1); border_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding); - painter.draw_text(border_rect, "border", font(), Gfx::TextAlignment::TopLeft, Color::Black); + painter.draw_text(border_rect, "border"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black); draw_size_texts(border_rect, Color::Black, m_node_box_sizing.border); // paint padding box @@ -99,7 +99,7 @@ void ElementSizePreviewWidget::paint_event(GUI::PaintEvent& event) draw_borders(padding_rect, Color::Black); padding_rect.shrink(1, 1, 1, 1); padding_rect.shrink(text_height_padding, text_width_padding, text_height_padding, text_width_padding); - painter.draw_text(padding_rect, "padding", font(), Gfx::TextAlignment::TopLeft, Color::Black); + painter.draw_text(padding_rect, "padding"sv, font(), Gfx::TextAlignment::TopLeft, Color::Black); draw_size_texts(padding_rect, Color::Black, m_node_box_sizing.padding); // paint content box diff --git a/Userland/Applications/Browser/IconBag.cpp b/Userland/Applications/Browser/IconBag.cpp index de7abafd4e2..05e738a9b6a 100644 --- a/Userland/Applications/Browser/IconBag.cpp +++ b/Userland/Applications/Browser/IconBag.cpp @@ -12,30 +12,30 @@ ErrorOr IconBag::try_create() { IconBag icon_bag; - icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png")); - icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png")); - icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png")); - icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png")); - icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png")); - icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png")); - icon_bag.go_home = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png")); - icon_bag.find = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png")); - icon_bag.color_chooser = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png")); - icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png")); - icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png")); - icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png")); - icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png")); - icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png")); - icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png")); - icon_bag.layers = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layers.png")); - icon_bag.filetype_css = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-css.png")); - icon_bag.inspect = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspect.png")); - icon_bag.history = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/history.png")); - icon_bag.cookie = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/cookie.png")); - icon_bag.local_storage = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/local-storage.png")); - icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png")); - icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png")); - icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png")); + icon_bag.filetype_html = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-html.png"sv)); + icon_bag.filetype_text = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-text.png"sv)); + icon_bag.filetype_javascript = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-javascript.png"sv)); + icon_bag.bookmark_contour = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-contour.png"sv)); + icon_bag.bookmark_filled = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bookmark-filled.png"sv)); + icon_bag.inspector_object = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv)); + icon_bag.go_home = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-home.png"sv)); + icon_bag.find = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)); + icon_bag.color_chooser = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png"sv)); + icon_bag.delete_icon = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv)); + icon_bag.new_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv)); + icon_bag.duplicate_tab = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/duplicate-tab.png"sv)); + icon_bag.code = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/code.png"sv)); + icon_bag.dom_tree = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/dom-tree.png"sv)); + icon_bag.layout = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"sv)); + icon_bag.layers = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layers.png"sv)); + icon_bag.filetype_css = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-css.png"sv)); + icon_bag.inspect = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspect.png"sv)); + icon_bag.history = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/history.png"sv)); + icon_bag.cookie = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/cookie.png"sv)); + icon_bag.local_storage = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/local-storage.png"sv)); + icon_bag.trash_can = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/trash-can.png"sv)); + icon_bag.clear_cache = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/browser/clear-cache.png"sv)); + icon_bag.spoof = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/spoof.png"sv)); return icon_bag; } diff --git a/Userland/Applications/Browser/InspectorWidget.cpp b/Userland/Applications/Browser/InspectorWidget.cpp index 43421608120..56f9fde607e 100644 --- a/Userland/Applications/Browser/InspectorWidget.cpp +++ b/Userland/Applications/Browser/InspectorWidget.cpp @@ -50,11 +50,11 @@ void InspectorWidget::set_selection(GUI::ModelIndex const index) VERIFY(json); Selection selection {}; - if (json->has_u32("pseudo-element")) { - selection.dom_node_id = json->get("parent-id").to_i32(); - selection.pseudo_element = static_cast(json->get("pseudo-element").to_u32()); + if (json->has_u32("pseudo-element"sv)) { + selection.dom_node_id = json->get("parent-id"sv).to_i32(); + selection.pseudo_element = static_cast(json->get("pseudo-element"sv).to_u32()); } else { - selection.dom_node_id = json->get("id").to_i32(); + selection.dom_node_id = json->get("id"sv).to_i32(); } if (selection == m_selection) @@ -186,21 +186,21 @@ void InspectorWidget::update_node_box_model(Optional node_box_sizing_jso auto json_value = json_or_error.release_value(); auto const& json_object = json_value.as_object(); - m_node_box_sizing.margin.top = json_object.get("margin_top").to_float(); - m_node_box_sizing.margin.right = json_object.get("margin_right").to_float(); - m_node_box_sizing.margin.bottom = json_object.get("margin_bottom").to_float(); - m_node_box_sizing.margin.left = json_object.get("margin_left").to_float(); - m_node_box_sizing.padding.top = json_object.get("padding_top").to_float(); - m_node_box_sizing.padding.right = json_object.get("padding_right").to_float(); - m_node_box_sizing.padding.bottom = json_object.get("padding_bottom").to_float(); - m_node_box_sizing.padding.left = json_object.get("padding_left").to_float(); - m_node_box_sizing.border.top = json_object.get("border_top").to_float(); - m_node_box_sizing.border.right = json_object.get("border_right").to_float(); - m_node_box_sizing.border.bottom = json_object.get("border_bottom").to_float(); - m_node_box_sizing.border.left = json_object.get("border_left").to_float(); + m_node_box_sizing.margin.top = json_object.get("margin_top"sv).to_float(); + m_node_box_sizing.margin.right = json_object.get("margin_right"sv).to_float(); + m_node_box_sizing.margin.bottom = json_object.get("margin_bottom"sv).to_float(); + m_node_box_sizing.margin.left = json_object.get("margin_left"sv).to_float(); + m_node_box_sizing.padding.top = json_object.get("padding_top"sv).to_float(); + m_node_box_sizing.padding.right = json_object.get("padding_right"sv).to_float(); + m_node_box_sizing.padding.bottom = json_object.get("padding_bottom"sv).to_float(); + m_node_box_sizing.padding.left = json_object.get("padding_left"sv).to_float(); + m_node_box_sizing.border.top = json_object.get("border_top"sv).to_float(); + m_node_box_sizing.border.right = json_object.get("border_right"sv).to_float(); + m_node_box_sizing.border.bottom = json_object.get("border_bottom"sv).to_float(); + m_node_box_sizing.border.left = json_object.get("border_left"sv).to_float(); - m_element_size_view->set_node_content_width(json_object.get("content_width").to_float()); - m_element_size_view->set_node_content_height(json_object.get("content_height").to_float()); + m_element_size_view->set_node_content_width(json_object.get("content_width"sv).to_float()); + m_element_size_view->set_node_content_height(json_object.get("content_height"sv).to_float()); m_element_size_view->set_box_model(m_node_box_sizing); } diff --git a/Userland/Applications/Browser/StorageWidget.cpp b/Userland/Applications/Browser/StorageWidget.cpp index 56991ba06df..bc45b55b74f 100644 --- a/Userland/Applications/Browser/StorageWidget.cpp +++ b/Userland/Applications/Browser/StorageWidget.cpp @@ -25,7 +25,7 @@ StorageWidget::StorageWidget() m_cookies_model = adopt_ref(*new CookiesModel()); m_cookies_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_cookies_model)); - m_cookies_filtering_model->set_filter_term(""); + m_cookies_filtering_model->set_filter_term(""sv); m_cookies_textbox->on_change = [this] { m_cookies_filtering_model->set_filter_term(m_cookies_textbox->text()); @@ -42,7 +42,7 @@ StorageWidget::StorageWidget() m_local_storage_model = adopt_ref(*new StorageModel()); m_local_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_local_storage_model)); - m_local_storage_filtering_model->set_filter_term(""); + m_local_storage_filtering_model->set_filter_term(""sv); m_local_storage_textbox->on_change = [this] { m_local_storage_filtering_model->set_filter_term(m_local_storage_textbox->text()); @@ -59,7 +59,7 @@ StorageWidget::StorageWidget() m_session_storage_model = adopt_ref(*new StorageModel()); m_session_storage_filtering_model = MUST(GUI::FilteringProxyModel::create(*m_session_storage_model)); - m_session_storage_filtering_model->set_filter_term(""); + m_session_storage_filtering_model->set_filter_term(""sv); m_session_storage_textbox->on_change = [this] { m_session_storage_filtering_model->set_filter_term(m_session_storage_textbox->text()); diff --git a/Userland/Applications/Browser/Tab.cpp b/Userland/Applications/Browser/Tab.cpp index e6eb96325b8..aa04c630021 100644 --- a/Userland/Applications/Browser/Tab.cpp +++ b/Userland/Applications/Browser/Tab.cpp @@ -42,8 +42,8 @@ namespace Browser { URL url_from_user_input(String const& input) { - if (input.starts_with("?") && !g_search_engine.is_empty()) - return URL(g_search_engine.replace("{}", URL::percent_encode(input.substring_view(1)), ReplaceMode::FirstOnly)); + if (input.starts_with('?') && !g_search_engine.is_empty()) + return URL(g_search_engine.replace("{}"sv, URL::percent_encode(input.substring_view(1)), ReplaceMode::FirstOnly)); URL url_with_http_schema = URL(String::formatted("http://{}", input)); if (url_with_http_schema.is_valid() && url_with_http_schema.port().has_value()) @@ -150,7 +150,7 @@ Tab::Tab(BrowserWindow& window) toolbar.add_action(window.reload_action()); m_location_box = toolbar.add(); - m_location_box->set_placeholder("Address"); + m_location_box->set_placeholder("Address"sv); m_location_box->on_return_pressed = [this] { auto url = url_from_location_bar(); @@ -166,7 +166,7 @@ Tab::Tab(BrowserWindow& window) m_location_box->add_custom_context_menu_action(GUI::Action::create("Paste && Go", [this](auto&) { auto [data, mime_type, _] = GUI::Clipboard::the().fetch_data_and_type(); - if (!mime_type.starts_with("text/")) + if (!mime_type.starts_with("text/"sv)) return; auto const& paste_text = data; if (paste_text.is_empty()) @@ -400,7 +400,7 @@ Tab::Tab(BrowserWindow& window) Optional Tab::url_from_location_bar(MayAppendTLD may_append_tld) { if (m_location_box->text().starts_with('?') && g_search_engine.is_empty()) { - GUI::MessageBox::show(&this->window(), "Select a search engine in the Settings menu before searching.", "No search engine selected", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(&this->window(), "Select a search engine in the Settings menu before searching."sv, "No search engine selected"sv, GUI::MessageBox::Type::Information); return {}; } @@ -410,8 +410,8 @@ Optional Tab::url_from_location_bar(MayAppendTLD may_append_tld) builder.append(text); if (may_append_tld == MayAppendTLD::Yes) { // FIXME: Expand the list of top level domains. - if (!(text.ends_with(".com") || text.ends_with(".net") || text.ends_with(".org"))) { - builder.append(".com"); + if (!(text.ends_with(".com"sv) || text.ends_with(".net"sv) || text.ends_with(".org"sv))) { + builder.append(".com"sv); } } String final_text = builder.to_string(); diff --git a/Userland/Applications/Browser/WindowActions.cpp b/Userland/Applications/Browser/WindowActions.cpp index 0af7bfedeee..68a22afc899 100644 --- a/Userland/Applications/Browser/WindowActions.cpp +++ b/Userland/Applications/Browser/WindowActions.cpp @@ -66,7 +66,7 @@ WindowActions::WindowActions(GUI::Window& window) m_tab_actions.last().set_status_tip("Switch to last tab"); m_about_action = GUI::Action::create( - "&About Browser", GUI::Icon::default_icon("app-browser").bitmap_for_size(16), [this](const GUI::Action&) { + "&About Browser", GUI::Icon::default_icon("app-browser"sv).bitmap_for_size(16), [this](const GUI::Action&) { if (on_about) on_about(); }, diff --git a/Userland/Applications/Browser/main.cpp b/Userland/Applications/Browser/main.cpp index 1c1f22ecc07..04a7ea46135 100644 --- a/Userland/Applications/Browser/main.cpp +++ b/Userland/Applications/Browser/main.cpp @@ -93,22 +93,22 @@ ErrorOr serenity_main(Main::Arguments arguments) Web::ResourceLoader::initialize(TRY(WebView::RequestServerAdapter::try_create())); - auto app_icon = GUI::Icon::default_icon("app-browser"); + auto app_icon = GUI::Icon::default_icon("app-browser"sv); - Browser::g_home_url = Config::read_string("Browser", "Preferences", "Home", "file:///res/html/misc/welcome.html"); - Browser::g_new_tab_url = Config::read_string("Browser", "Preferences", "NewTab", "file:///res/html/misc/new-tab.html"); - Browser::g_search_engine = Config::read_string("Browser", "Preferences", "SearchEngine", {}); - Browser::g_content_filters_enabled = Config::read_bool("Browser", "Preferences", "EnableContentFilters", true); + Browser::g_home_url = Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, "file:///res/html/misc/welcome.html"sv); + Browser::g_new_tab_url = Config::read_string("Browser"sv, "Preferences"sv, "NewTab"sv, "file:///res/html/misc/new-tab.html"sv); + Browser::g_search_engine = Config::read_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, {}); + Browser::g_content_filters_enabled = Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, true); Browser::g_icon_bag = TRY(Browser::IconBag::try_create()); TRY(load_content_filters()); - for (auto& group : Config::list_groups("Browser")) { - if (!group.starts_with("Proxy:")) + for (auto& group : Config::list_groups("Browser"sv)) { + if (!group.starts_with("Proxy:"sv)) continue; - for (auto& key : Config::list_keys("Browser", group)) { + for (auto& key : Config::list_keys("Browser"sv, group)) { auto proxy_spec = group.substring_view(6); auto existing_proxy = Browser::g_proxies.find(proxy_spec); if (existing_proxy.is_end()) diff --git a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp index fc739bb8036..9a5fb3417fb 100644 --- a/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/BrowserSettingsWidget.cpp @@ -62,22 +62,22 @@ BrowserSettingsWidget::BrowserSettingsWidget() load_from_gml(browser_settings_widget_gml); m_homepage_url_textbox = find_descendant_of_type_named("homepage_url_textbox"); - m_homepage_url_textbox->set_text(Config::read_string("Browser", "Preferences", "Home", default_homepage_url), GUI::AllowCallback::No); + m_homepage_url_textbox->set_text(Config::read_string("Browser"sv, "Preferences"sv, "Home"sv, default_homepage_url), GUI::AllowCallback::No); m_homepage_url_textbox->on_change = [&]() { set_modified(true); }; m_new_tab_url_textbox = find_descendant_of_type_named("new_tab_url_textbox"); - m_new_tab_url_textbox->set_text(Config::read_string("Browser", "Preferences", "NewTab", default_new_tab_url), GUI::AllowCallback::No); + m_new_tab_url_textbox->set_text(Config::read_string("Browser"sv, "Preferences"sv, "NewTab"sv, default_new_tab_url), GUI::AllowCallback::No); m_new_tab_url_textbox->on_change = [&]() { set_modified(true); }; m_color_scheme_combobox = find_descendant_of_type_named("color_scheme_combobox"); m_color_scheme_combobox->set_only_allow_values_from_model(true); m_color_scheme_combobox->set_model(adopt_ref(*new ColorSchemeModel())); m_color_scheme_combobox->set_selected_index(0, GUI::AllowCallback::No); - set_color_scheme(Config::read_string("Browser", "Preferences", "ColorScheme", default_color_scheme)); + set_color_scheme(Config::read_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, default_color_scheme)); m_color_scheme_combobox->on_change = [&](auto, auto) { set_modified(true); }; m_show_bookmarks_bar_checkbox = find_descendant_of_type_named("show_bookmarks_bar_checkbox"); - m_show_bookmarks_bar_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "ShowBookmarksBar", default_show_bookmarks_bar), GUI::AllowCallback::No); + m_show_bookmarks_bar_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, default_show_bookmarks_bar), GUI::AllowCallback::No); m_show_bookmarks_bar_checkbox->on_checked = [&](auto) { set_modified(true); }; m_enable_search_engine_checkbox = find_descendant_of_type_named("enable_search_engine_checkbox"); @@ -111,10 +111,10 @@ BrowserSettingsWidget::BrowserSettingsWidget() m_custom_search_engine_group->set_enabled(m_is_custom_search_engine); set_modified(true); }; - set_search_engine_url(Config::read_string("Browser", "Preferences", "SearchEngine", default_search_engine)); + set_search_engine_url(Config::read_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, default_search_engine)); m_auto_close_download_windows_checkbox = find_descendant_of_type_named("auto_close_download_windows_checkbox"); - m_auto_close_download_windows_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", default_auto_close_download_windows), GUI::AllowCallback::No); + m_auto_close_download_windows_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, default_auto_close_download_windows), GUI::AllowCallback::No); m_auto_close_download_windows_checkbox->on_checked = [&](auto) { set_modified(true); }; } @@ -170,39 +170,39 @@ void BrowserSettingsWidget::apply_settings() { auto homepage_url = m_homepage_url_textbox->text(); if (!URL(homepage_url).is_valid()) { - GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid"); + GUI::MessageBox::show_error(this->window(), "The homepage URL you have entered is not valid"sv); m_homepage_url_textbox->select_all(); m_homepage_url_textbox->set_focus(true); return; } - Config::write_string("Browser", "Preferences", "Home", homepage_url); + Config::write_string("Browser"sv, "Preferences"sv, "Home"sv, homepage_url); auto new_tab_url = m_new_tab_url_textbox->text(); if (!URL(new_tab_url).is_valid()) { - GUI::MessageBox::show_error(this->window(), "The new tab URL you have entered is not valid"); + GUI::MessageBox::show_error(this->window(), "The new tab URL you have entered is not valid"sv); m_new_tab_url_textbox->select_all(); m_new_tab_url_textbox->set_focus(true); return; } - Config::write_string("Browser", "Preferences", "NewTab", new_tab_url); + Config::write_string("Browser"sv, "Preferences"sv, "NewTab"sv, new_tab_url); - Config::write_bool("Browser", "Preferences", "ShowBookmarksBar", m_show_bookmarks_bar_checkbox->is_checked()); + Config::write_bool("Browser"sv, "Preferences"sv, "ShowBookmarksBar"sv, m_show_bookmarks_bar_checkbox->is_checked()); auto color_scheme_index = m_color_scheme_combobox->selected_index(); auto color_scheme = m_color_scheme_combobox->model()->index(color_scheme_index, 1).data().to_string(); - Config::write_string("Browser", "Preferences", "ColorScheme", color_scheme); + Config::write_string("Browser"sv, "Preferences"sv, "ColorScheme"sv, color_scheme); if (!m_enable_search_engine_checkbox->is_checked()) { - Config::write_string("Browser", "Preferences", "SearchEngine", {}); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, {}); } else if (m_is_custom_search_engine) { - Config::write_string("Browser", "Preferences", "SearchEngine", m_custom_search_engine_textbox->text()); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, m_custom_search_engine_textbox->text()); } else { auto selected_index = m_search_engine_combobox->selected_index(); auto url = m_search_engine_combobox->model()->index(selected_index, 1).data().to_string(); - Config::write_string("Browser", "Preferences", "SearchEngine", url); + Config::write_string("Browser"sv, "Preferences"sv, "SearchEngine"sv, url); } - Config::write_bool("Browser", "Preferences", "CloseDownloadWidgetOnFinish", m_auto_close_download_windows_checkbox->is_checked()); + Config::write_bool("Browser"sv, "Preferences"sv, "CloseDownloadWidgetOnFinish"sv, m_auto_close_download_windows_checkbox->is_checked()); } void BrowserSettingsWidget::reset_default_values() diff --git a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp index 7770fc083e2..8d583c08f2d 100644 --- a/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp +++ b/Userland/Applications/BrowserSettings/ContentFilterSettingsWidget.cpp @@ -114,13 +114,13 @@ ContentFilterSettingsWidget::ContentFilterSettingsWidget() m_domain_list_view = find_descendant_of_type_named("domain_list_view"); m_add_new_domain_button = find_descendant_of_type_named("add_new_domain_button"); - m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser", "Preferences", "EnableContentFilters", s_default_enable_content_filtering), GUI::AllowCallback::No); + m_enable_content_filtering_checkbox->set_checked(Config::read_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, s_default_enable_content_filtering), GUI::AllowCallback::No); m_enable_content_filtering_checkbox->on_checked = [&](auto) { set_modified(true); }; m_add_new_domain_button->on_click = [&](unsigned) { String text; - if (GUI::InputBox::show(window(), text, "Enter domain name", "Add domain to Content Filter") == GUI::Dialog::ExecResult::OK + if (GUI::InputBox::show(window(), text, "Enter domain name"sv, "Add domain to Content Filter"sv) == GUI::Dialog::ExecResult::OK && !text.is_empty()) { m_domain_list_model->add_domain(std::move(text)); set_modified(true); @@ -151,7 +151,7 @@ void ContentFilterSettingsWidget::apply_settings() { // FIXME: Propagate errors MUST(m_domain_list_model->save()); - Config::write_bool("Browser", "Preferences", "EnableContentFilters", m_enable_content_filtering_checkbox->is_checked()); + Config::write_bool("Browser"sv, "Preferences"sv, "EnableContentFilters"sv, m_enable_content_filtering_checkbox->is_checked()); } void ContentFilterSettingsWidget::reset_default_values() diff --git a/Userland/Applications/BrowserSettings/main.cpp b/Userland/Applications/BrowserSettings/main.cpp index 4c4527b5f5b..bfcbf26b542 100644 --- a/Userland/Applications/BrowserSettings/main.cpp +++ b/Userland/Applications/BrowserSettings/main.cpp @@ -30,12 +30,12 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/home/anon/.config/BrowserContentFilters.txt", "rwc")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-browser"); + auto app_icon = GUI::Icon::default_icon("app-browser"sv); auto window = TRY(GUI::SettingsWindow::create("Browser Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); window->set_icon(app_icon.bitmap_for_size(16)); - (void)TRY(window->add_tab("Browser", "browser")); - (void)TRY(window->add_tab("Content Filtering", "content-filtering")); + (void)TRY(window->add_tab("Browser"sv, "browser"sv)); + (void)TRY(window->add_tab("Content Filtering"sv, "content-filtering"sv)); window->set_active_tab(selected_tab); window->show(); diff --git a/Userland/Applications/Calculator/main.cpp b/Userland/Applications/Calculator/main.cpp index 8fa27be759b..91035a66f53 100644 --- a/Userland/Applications/Calculator/main.cpp +++ b/Userland/Applications/Calculator/main.cpp @@ -27,7 +27,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-calculator"); + auto app_icon = GUI::Icon::default_icon("app-calculator"sv); auto window = TRY(GUI::Window::try_create()); window->set_title("Calculator"); @@ -57,13 +57,13 @@ ErrorOr serenity_main(Main::Arguments arguments) })); auto& constants_menu = window->add_menu("&Constants"); - constants_menu.add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/pi.png")), [&](auto&) { + constants_menu.add_action(GUI::Action::create("&Pi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/pi.png"sv)), [&](auto&) { widget->set_entry(KeypadValue { 31415926535, 10 }); })); - constants_menu.add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/eulers_number.png")), [&](auto&) { + constants_menu.add_action(GUI::Action::create("&Euler's Number", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/eulers_number.png"sv)), [&](auto&) { widget->set_entry(KeypadValue { 27182818284, 10 }); })); - constants_menu.add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/phi.png")), [&](auto&) { + constants_menu.add_action(GUI::Action::create("&Phi", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/calculator/phi.png"sv)), [&](auto&) { widget->set_entry(KeypadValue { 16180339887, 10 }); })); diff --git a/Userland/Applications/Calendar/main.cpp b/Userland/Applications/Calendar/main.cpp index 7845517f2f0..3a7ba07dddc 100644 --- a/Userland/Applications/Calendar/main.cpp +++ b/Userland/Applications/Calendar/main.cpp @@ -31,7 +31,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-calendar")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-calendar"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("Calendar"); window->resize(600, 480); @@ -44,7 +44,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto toolbar = main_widget->find_descendant_of_type_named("toolbar"); auto calendar = main_widget->find_descendant_of_type_named("calendar"); - auto prev_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](const GUI::Action&) { + auto prev_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](const GUI::Action&) { unsigned view_month = calendar->view_month(); unsigned view_year = calendar->view_year(); if (calendar->mode() == GUI::Calendar::Month) { @@ -59,7 +59,7 @@ ErrorOr serenity_main(Main::Arguments arguments) calendar->update_tiles(view_year, view_month); }); - auto next_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](const GUI::Action&) { + auto next_date_action = GUI::Action::create({}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](const GUI::Action&) { unsigned view_month = calendar->view_month(); unsigned view_year = calendar->view_year(); if (calendar->mode() == GUI::Calendar::Month) { @@ -74,22 +74,22 @@ ErrorOr serenity_main(Main::Arguments arguments) calendar->update_tiles(view_year, view_month); }); - auto add_event_action = GUI::Action::create("&Add Event", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png")), [&](const GUI::Action&) { + auto add_event_action = GUI::Action::create("&Add Event", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"sv)), [&](const GUI::Action&) { AddEventDialog::show(calendar->selected_date(), window); }); - auto jump_to_action = GUI::Action::create("Jump to &Today", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png")), [&](const GUI::Action&) { + auto jump_to_action = GUI::Action::create("Jump to &Today", {}, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png"sv)), [&](const GUI::Action&) { calendar->set_selected_date(Core::DateTime::now()); calendar->update_tiles(Core::DateTime::now().year(), Core::DateTime::now().month()); }); - auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png")), [&](const GUI::Action&) { + auto view_month_action = GUI::Action::create_checkable("&Month View", { Mod_Ctrl, KeyCode::Key_1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-month-view.png"sv)), [&](const GUI::Action&) { if (calendar->mode() == GUI::Calendar::Year) calendar->toggle_mode(); }); view_month_action->set_checked(true); - auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png")), [&](const GUI::Action&) { + auto view_year_action = GUI::Action::create_checkable("&Year View", { Mod_Ctrl, KeyCode::Key_2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"sv)), [&](const GUI::Action&) { if (calendar->mode() == GUI::Calendar::Month) calendar->toggle_mode(); }); @@ -117,7 +117,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }; auto& file_menu = window->add_menu("&File"); - file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png")), + file_menu.add_action(GUI::Action::create("&Add Event", { Mod_Ctrl | Mod_Shift, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/add-event.png"sv)), [&](const GUI::Action&) { AddEventDialog::show(calendar->selected_date(), window); })); diff --git a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp index da03b59645f..c4486243528 100644 --- a/Userland/Applications/CharacterMap/CharacterMapWidget.cpp +++ b/Userland/Applications/CharacterMap/CharacterMapWidget.cpp @@ -37,11 +37,11 @@ CharacterMapWidget::CharacterMapWidget() m_statusbar = find_descendant_of_type_named("statusbar"); m_unicode_block_listview = find_descendant_of_type_named("unicode_block_listview"); - m_choose_font_action = GUI::Action::create("Choose Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_choose_font_action = GUI::Action::create("Choose Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto font_picker = GUI::FontPicker::construct(window(), &font(), false); if (font_picker->exec() == GUI::Dialog::ExecResult::OK) { auto& font = *font_picker->font(); - Config::write_string("CharacterMap", "History", "Font", font.qualified_name()); + Config::write_string("CharacterMap"sv, "History"sv, "Font"sv, font.qualified_name()); set_font(font); } }); @@ -58,19 +58,19 @@ CharacterMapWidget::CharacterMapWidget() }); m_copy_selection_action->set_status_tip("Copy the highlighted characters to the clipboard"); - m_previous_glyph_action = GUI::Action::create("Previous character", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_previous_glyph_action = GUI::Action::create("Previous character", { Mod_Alt, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_glyph_map->select_previous_existing_glyph(); }); m_previous_glyph_action->set_status_tip("Seek the previous visible glyph"); - m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_glyph_map->select_next_existing_glyph(); }); m_next_glyph_action->set_status_tip("Seek the next visible glyph"); - m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_go_to_glyph_action = GUI::Action::create("Go to glyph...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { String input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; @@ -83,7 +83,7 @@ CharacterMapWidget::CharacterMapWidget() }); m_go_to_glyph_action->set_status_tip("Go to the specified code point"); - m_find_glyphs_action = GUI::Action::create("&Find glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_find_glyphs_action = GUI::Action::create("&Find glyphs...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { if (m_find_window.is_null()) { m_find_window = GUI::Window::construct(window()); auto& search_widget = m_find_window->set_main_widget(); @@ -91,7 +91,7 @@ CharacterMapWidget::CharacterMapWidget() m_glyph_map->set_active_glyph(code_point); m_glyph_map->scroll_to_glyph(code_point); }; - m_find_window->set_icon(GUI::Icon::try_create_default_icon("find").value().bitmap_for_size(16)); + m_find_window->set_icon(GUI::Icon::try_create_default_icon("find"sv).value().bitmap_for_size(16)); m_find_window->set_title("Find a character"); m_find_window->resize(300, 400); } @@ -159,7 +159,7 @@ void CharacterMapWidget::initialize_menubar(GUI::Window& window) help_menu.add_action(GUI::CommonActions::make_help_action([&](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/CharacterMap.md"), "/bin/Help"); })); - help_menu.add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("Character Map", GUI::Icon::default_icon("app-character-map"sv), &window)); } void CharacterMapWidget::did_change_font() diff --git a/Userland/Applications/CharacterMap/main.cpp b/Userland/Applications/CharacterMap/main.cpp index af90ec4bed3..b293f069952 100644 --- a/Userland/Applications/CharacterMap/main.cpp +++ b/Userland/Applications/CharacterMap/main.cpp @@ -24,7 +24,7 @@ static void search_and_print_results(String const& query) for_each_character_containing(query, [&](auto code_point, auto display_name) { StringBuilder builder; builder.append_code_point(code_point); - builder.append(" - "); + builder.append(" - "sv); builder.append(display_name); outln(builder.string_view()); result_count++; @@ -62,7 +62,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return 0; } - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-character-map")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-character-map"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("Character Map"); window->set_icon(app_icon.bitmap_for_size(16)); @@ -71,7 +71,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto character_map_widget = TRY(window->try_set_main_widget()); character_map_widget->initialize_menubar(*window); - auto font_query = Config::read_string("CharacterMap", "History", "Font", Gfx::FontDatabase::the().default_font_query()); + auto font_query = Config::read_string("CharacterMap"sv, "History"sv, "Font"sv, Gfx::FontDatabase::the().default_font_query()); character_map_widget->set_font(Gfx::FontDatabase::the().get_by_name(font_query)); window->show(); diff --git a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp index dfb5edf1566..f16c70f6bdc 100644 --- a/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/ClockSettingsWidget.cpp @@ -14,10 +14,10 @@ #include #include -constexpr StringView time_format_12h = "%I:%M %p"; -constexpr StringView time_format_12h_seconds = "%r"; -constexpr StringView time_format_24h = "%R"; -constexpr StringView time_format_24h_seconds = "%T"; +constexpr auto time_format_12h = "%I:%M %p"sv; +constexpr auto time_format_12h_seconds = "%r"sv; +constexpr auto time_format_24h = "%R"sv; +constexpr auto time_format_24h_seconds = "%T"sv; ClockSettingsWidget::ClockSettingsWidget() { @@ -29,7 +29,7 @@ ClockSettingsWidget::ClockSettingsWidget() auto& custom_radio = *find_descendant_of_type_named("custom_radio"); m_clock_preview = *find_descendant_of_type_named("clock_preview"); - m_time_format = Config::read_string("Taskbar", "Clock", "TimeFormat"); + m_time_format = Config::read_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv); m_custom_format_input = *find_descendant_of_type_named("custom_format_input"); m_custom_format_input->set_text(m_time_format); m_custom_format_input->set_enabled(false); @@ -96,14 +96,14 @@ ClockSettingsWidget::ClockSettingsWidget() void ClockSettingsWidget::apply_settings() { - Config::write_string("Taskbar", "Clock", "TimeFormat", m_custom_format_input->text()); + Config::write_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, m_custom_format_input->text()); } void ClockSettingsWidget::reset_default_values() { m_24_hour_radio->set_checked(true); m_show_seconds_checkbox->set_checked(true); - Config::write_string("Taskbar", "Clock", "TimeFormat", time_format_24h_seconds); + Config::write_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, time_format_24h_seconds); } void ClockSettingsWidget::update_time_format_string() diff --git a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp index 75a411ca4bc..7aecbc858cc 100644 --- a/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp +++ b/Userland/Applications/ClockSettings/TimeZoneSettingsWidget.cpp @@ -62,7 +62,7 @@ TimeZoneSettingsWidget::TimeZoneSettingsWidget() m_time_zone_map = *find_descendant_of_type_named("time_zone_map"); m_time_zone_map->set_bitmap(time_zone_map_bitmap); - auto time_zone_marker = Gfx::Bitmap::try_load_from_file("/res/icons/32x32/ladyball.png").release_value_but_fixme_should_propagate_errors(); + auto time_zone_marker = Gfx::Bitmap::try_load_from_file("/res/icons/32x32/ladyball.png"sv).release_value_but_fixme_should_propagate_errors(); m_time_zone_marker = time_zone_marker->scaled(0.75f, 0.75f).release_value_but_fixme_should_propagate_errors(); set_time_zone_location(); @@ -159,5 +159,5 @@ Optional TimeZoneSettingsWidget::compute_time_zone_location() c void TimeZoneSettingsWidget::set_time_zone() { - GUI::Process::spawn_or_show_error(window(), "/bin/timezone", Array { m_time_zone.characters() }); + GUI::Process::spawn_or_show_error(window(), "/bin/timezone"sv, Array { m_time_zone.characters() }); } diff --git a/Userland/Applications/ClockSettings/main.cpp b/Userland/Applications/ClockSettings/main.cpp index 8b3918ab1b3..3c621654f91 100644 --- a/Userland/Applications/ClockSettings/main.cpp +++ b/Userland/Applications/ClockSettings/main.cpp @@ -33,11 +33,11 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/etc/timezone", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-analog-clock"); // FIXME: Create a ClockSettings icon. + auto app_icon = GUI::Icon::default_icon("app-analog-clock"sv); // FIXME: Create a ClockSettings icon. auto window = TRY(GUI::SettingsWindow::create("Clock Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); - (void)TRY(window->add_tab("Clock", "clock")); - (void)TRY(window->add_tab("Time Zone", "time-zone")); + (void)TRY(window->add_tab("Clock"sv, "clock"sv)); + (void)TRY(window->add_tab("Time Zone"sv, "time-zone"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->resize(540, 570); window->set_active_tab(selected_tab); diff --git a/Userland/Applications/CrashReporter/main.cpp b/Userland/Applications/CrashReporter/main.cpp index 4dde3ea01d0..f275fddf9b5 100644 --- a/Userland/Applications/CrashReporter/main.cpp +++ b/Userland/Applications/CrashReporter/main.cpp @@ -73,9 +73,9 @@ static TitleAndText build_backtrace(Coredump::Reader const& coredump, ELF::Core: }; if (metadata.contains("assertion")) - prepend_metadata("assertion", "ASSERTION FAILED: {}"); + prepend_metadata("assertion", "ASSERTION FAILED: {}"sv); else if (metadata.contains("pledge_violation")) - prepend_metadata("pledge_violation", "Has not pledged {}"); + prepend_metadata("pledge_violation", "Has not pledged {}"sv); auto fault_address = metadata.get("fault_address"); auto fault_type = metadata.get("fault_type"); @@ -168,7 +168,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto pid = coredump->process_pid(); auto termination_signal = coredump->process_termination_signal(); - auto app_icon = GUI::Icon::default_icon("app-crash-reporter"); + auto app_icon = GUI::Icon::default_icon("app-crash-reporter"sv); auto window = TRY(GUI::Window::try_create()); window->set_title("Crash Reporter"); @@ -263,16 +263,16 @@ ErrorOr serenity_main(Main::Arguments arguments) }; auto& debug_button = *widget->find_descendant_of_type_named("debug_button"); - debug_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png"))); + debug_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png"sv))); debug_button.on_click = [&](int) { - GUI::Process::spawn_or_show_error(window, "/bin/HackStudio", Array { "-c", coredump_path.characters() }); + GUI::Process::spawn_or_show_error(window, "/bin/HackStudio"sv, Array { "-c", coredump_path.characters() }); }; auto& save_backtrace_button = *widget->find_descendant_of_type_named("save_backtrace_button"); - save_backtrace_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"))); + save_backtrace_button.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"sv))); save_backtrace_button.on_click = [&](auto) { if (full_backtrace.is_empty()) { - GUI::MessageBox::show(window, "Backtrace has not been generated yet. Please wait...", "Empty Backtrace", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Backtrace has not been generated yet. Please wait..."sv, "Empty Backtrace"sv, GUI::MessageBox::Type::Error); return; } @@ -283,7 +283,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = file_or_error.value(); if (!file->write(full_backtrace.to_string())) - GUI::MessageBox::show(window, String::formatted("Couldn't save file: {}.", file_or_error.error()), "Saving backtrace failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Couldn't save file: {}.", file_or_error.error()), "Saving backtrace failed"sv, GUI::MessageBox::Type::Error); }; (void)Threading::BackgroundAction::construct( diff --git a/Userland/Applications/Debugger/main.cpp b/Userland/Applications/Debugger/main.cpp index faba3a3260c..2df83b3152e 100644 --- a/Userland/Applications/Debugger/main.cpp +++ b/Userland/Applications/Debugger/main.cpp @@ -154,7 +154,7 @@ static bool handle_breakpoint_command(String const& command) if (argument.is_empty()) return false; - if (argument.contains(":")) { + if (argument.contains(":"sv)) { auto source_arguments = argument.split(':'); if (source_arguments.size() != 2) return false; @@ -164,7 +164,7 @@ static bool handle_breakpoint_command(String const& command) auto file = source_arguments[0]; return insert_breakpoint_at_source_position(file, line.value()); } - if ((argument.starts_with("0x"))) { + if ((argument.starts_with("0x"sv))) { return insert_breakpoint_at_address(strtoul(argument.characters() + 2, nullptr, 16)); } @@ -181,7 +181,7 @@ static bool handle_examine_command(String const& command) if (argument.is_empty()) return false; - if (!(argument.starts_with("0x"))) { + if (!(argument.starts_with("0x"sv))) { return false; } FlatPtr address = strtoul(argument.characters() + 2, nullptr, 16); @@ -309,14 +309,14 @@ ErrorOr serenity_main(Main::Arguments arguments) handle_print_registers(regs); success = true; - } else if (command.starts_with("dis")) { + } else if (command.starts_with("dis"sv)) { success = handle_disassemble_command(command, ip); - } else if (command.starts_with("bp")) { + } else if (command.starts_with("bp"sv)) { success = handle_breakpoint_command(command); - } else if (command.starts_with("x")) { + } else if (command.starts_with("x"sv)) { success = handle_examine_command(command); - } else if (command.starts_with("bt")) { + } else if (command.starts_with("bt"sv)) { success = handle_backtrace_command(regs); } diff --git a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp index 1a02a50ef20..d0a47a3f5b6 100644 --- a/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp @@ -65,7 +65,7 @@ void BackgroundSettingsWidget::create_frame() }; m_context_menu = GUI::Menu::construct(); - m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) { + m_show_in_file_manager_action = GUI::Action::create("Show in File Manager", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) { LexicalPath path { m_monitor_widget->wallpaper() }; Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename())); }); @@ -88,7 +88,7 @@ void BackgroundSettingsWidget::create_frame() auto& button = *find_descendant_of_type_named("wallpaper_open_button"); button.on_click = [this](auto) { - auto path = GUI::FilePicker::get_open_filepath(window(), "Select wallpaper from file system", "/res/wallpapers"); + auto path = GUI::FilePicker::get_open_filepath(window(), "Select wallpaper from file system", "/res/wallpapers"sv); if (!path.has_value()) return; m_wallpaper_view->selection().clear(); @@ -124,7 +124,7 @@ void BackgroundSettingsWidget::load_current_settings() { auto ws_config = Core::ConfigFile::open("/etc/WindowServer.ini").release_value_but_fixme_should_propagate_errors(); - auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", ""); + auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv); if (!selected_wallpaper.is_empty()) { auto index = static_cast(m_wallpaper_view->model())->index(selected_wallpaper, m_wallpaper_view->model_column()); m_wallpaper_view->set_cursor(index, GUI::AbstractView::SelectionUpdate::Set); diff --git a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp index ba38f72e4a0..2c2901ffffd 100644 --- a/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/DesktopSettingsWidget.cpp @@ -50,7 +50,7 @@ void DesktopSettingsWidget::apply_settings() if (workspace_rows != desktop.workspace_rows() || workspace_columns != desktop.workspace_columns()) { if (!GUI::ConnectionToWindowServer::the().apply_workspace_settings(workspace_rows, workspace_columns, true)) { GUI::MessageBox::show(window(), String::formatted("Error applying workspace settings"), - "Workspace settings", GUI::MessageBox::Type::Error); + "Workspace settings"sv, GUI::MessageBox::Type::Error); } } } diff --git a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp index d5049e4084e..5bdf07ec9e3 100644 --- a/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorSettingsWidget.cpp @@ -239,7 +239,7 @@ void MonitorSettingsWidget::apply_settings() seconds_until_revert, seconds_until_revert == 1 ? "second" : "seconds"); }; - auto box = GUI::MessageBox::construct(window(), box_text(), "Apply new screen layout", + auto box = GUI::MessageBox::construct(window(), box_text(), "Apply new screen layout"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); box->set_icon(window()->icon()); @@ -258,20 +258,20 @@ void MonitorSettingsWidget::apply_settings() auto save_result = GUI::ConnectionToWindowServer::the().save_screen_layout(); if (!save_result.success()) { GUI::MessageBox::show(window(), String::formatted("Error saving settings: {}", save_result.error_msg()), - "Unable to save setting", GUI::MessageBox::Type::Error); + "Unable to save setting"sv, GUI::MessageBox::Type::Error); } } else { auto restore_result = GUI::ConnectionToWindowServer::the().set_screen_layout(current_layout, false); if (!restore_result.success()) { GUI::MessageBox::show(window(), String::formatted("Error restoring settings: {}", restore_result.error_msg()), - "Unable to restore setting", GUI::MessageBox::Type::Error); + "Unable to restore setting"sv, GUI::MessageBox::Type::Error); } else { load_current_settings(); } } } else { GUI::MessageBox::show(window(), String::formatted("Error setting screen layout: {}", result.error_msg()), - "Unable to apply changes", GUI::MessageBox::Type::Error); + "Unable to apply changes"sv, GUI::MessageBox::Type::Error); } } } diff --git a/Userland/Applications/DisplaySettings/MonitorWidget.cpp b/Userland/Applications/DisplaySettings/MonitorWidget.cpp index cb56366ebd5..0bf92e337bf 100644 --- a/Userland/Applications/DisplaySettings/MonitorWidget.cpp +++ b/Userland/Applications/DisplaySettings/MonitorWidget.cpp @@ -19,7 +19,7 @@ namespace DisplaySettings { MonitorWidget::MonitorWidget() { m_desktop_resolution = GUI::Desktop::the().rect().size(); - m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png").release_value_but_fixme_should_propagate_errors(); + m_monitor_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/monitor.png"sv).release_value_but_fixme_should_propagate_errors(); m_desktop_bitmap = Gfx::Bitmap::try_create(m_monitor_bitmap->format(), { 280, 158 }).release_value_but_fixme_should_propagate_errors(); m_monitor_rect = { { 12, 13 }, m_desktop_bitmap->size() }; set_fixed_size(304, 201); diff --git a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp index 6e4bb77e1b9..d4593abad84 100644 --- a/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemePreviewWidget.cpp @@ -39,9 +39,9 @@ void ThemePreviewWidget::paint_preview(GUI::PaintEvent&) }; center_window_group_within(window_group, frame_inner_rect()); - paint_window("Inactive Window", inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, inactive_window_icon()); - paint_window("Active Window", active_window_rect, Gfx::WindowTheme::WindowState::Active, active_window_icon()); - paint_window("Alert", message_box, Gfx::WindowTheme::WindowState::Highlighted, active_window_icon(), 1); + paint_window("Inactive Window"sv, inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, inactive_window_icon()); + paint_window("Active Window"sv, active_window_rect, Gfx::WindowTheme::WindowState::Active, active_window_icon()); + paint_window("Alert"sv, message_box, Gfx::WindowTheme::WindowState::Highlighted, active_window_icon(), 1); auto draw_centered_button = [&](auto window_rect, auto text, int button_width, int button_height) { Gfx::IntRect button_rect { 0, 0, button_width, button_height }; @@ -50,7 +50,7 @@ void ThemePreviewWidget::paint_preview(GUI::PaintEvent&) painter.draw_text(button_rect, text, Gfx::TextAlignment::Center, preview_palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap); }; - draw_centered_button(message_box, "Ok", 32, 16); + draw_centered_button(message_box, "Ok"sv, 32, 16); } } diff --git a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp index e2e9848dfe5..36c47742427 100644 --- a/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp +++ b/Userland/Applications/DisplaySettings/ThemesSettingsWidget.cpp @@ -45,11 +45,11 @@ ThemesSettingsWidget::ThemesSettingsWidget(bool& background_settings_changed) }; m_themes_combo->set_selected_index(current_theme_index, GUI::AllowCallback::No); - auto mouse_settings_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mouse.png").release_value_but_fixme_should_propagate_errors(); + auto mouse_settings_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mouse.png"sv).release_value_but_fixme_should_propagate_errors(); m_cursor_themes_button = *find_descendant_of_type_named("cursor_themes_button"); m_cursor_themes_button->set_icon(mouse_settings_icon); m_cursor_themes_button->on_click = [&](auto) { - GUI::Process::spawn_or_show_error(window(), "/bin/MouseSettings", Array { "-t", "cursor-theme" }); + GUI::Process::spawn_or_show_error(window(), "/bin/MouseSettings"sv, Array { "-t", "cursor-theme" }); }; GUI::Application::the()->on_theme_change = [&]() { diff --git a/Userland/Applications/DisplaySettings/main.cpp b/Userland/Applications/DisplaySettings/main.cpp index 2b83b5f5c53..0794fd41ea5 100644 --- a/Userland/Applications/DisplaySettings/main.cpp +++ b/Userland/Applications/DisplaySettings/main.cpp @@ -31,16 +31,16 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(selected_tab, "Tab, one of 'background', 'fonts', 'monitor', 'themes', or 'workspaces'", "open-tab", 't', "tab"); args_parser.parse(arguments); - auto app_icon = GUI::Icon::default_icon("app-display-settings"); + auto app_icon = GUI::Icon::default_icon("app-display-settings"sv); bool background_settings_changed = false; auto window = TRY(GUI::SettingsWindow::create("Display Settings")); - (void)TRY(window->add_tab("Background", "background", background_settings_changed)); - (void)TRY(window->add_tab("Themes", "themes", background_settings_changed)); - (void)TRY(window->add_tab("Fonts", "fonts")); - (void)TRY(window->add_tab("Monitor", "monitor")); - (void)TRY(window->add_tab("Workspaces", "workspaces")); + (void)TRY(window->add_tab("Background"sv, "background"sv, background_settings_changed)); + (void)TRY(window->add_tab("Themes"sv, "themes"sv, background_settings_changed)); + (void)TRY(window->add_tab("Fonts"sv, "fonts"sv)); + (void)TRY(window->add_tab("Monitor"sv, "monitor"sv)); + (void)TRY(window->add_tab("Workspaces"sv, "workspaces"sv)); window->set_active_tab(selected_tab); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp index c0bbbd61bdc..21ca93702e2 100644 --- a/Userland/Applications/FileManager/DirectoryView.cpp +++ b/Userland/Applications/FileManager/DirectoryView.cpp @@ -125,7 +125,7 @@ void DirectoryView::handle_activation(GUI::ModelIndex const& index) unsetenv("__libgui_launch_origin_rect"); } else { auto error_message = String::formatted("Could not open {}", path); - GUI::MessageBox::show(window(), error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), error_message, "File Manager"sv, GUI::MessageBox::Type::Error); } } @@ -332,10 +332,10 @@ void DirectoryView::set_view_mode_from_string(String const& mode) if (m_mode == Mode::Desktop) return; - if (mode.contains("Table")) { + if (mode.contains("Table"sv)) { set_view_mode(DirectoryView::ViewMode::Table); m_view_as_table_action->set_checked(true); - } else if (mode.contains("Columns")) { + } else if (mode.contains("Columns"sv)) { set_view_mode(DirectoryView::ViewMode::Columns); m_view_as_columns_action->set_checked(true); } else { @@ -462,7 +462,7 @@ void DirectoryView::update_statusbar() if (selected_item_count == 1) { auto& node = this->node(current_view().selection().first()); if (!node.symlink_target.is_empty()) { - builder.append(" → "); + builder.append(" → "sv); builder.append(node.symlink_target); } } @@ -550,37 +550,37 @@ void DirectoryView::handle_selection_change() void DirectoryView::setup_actions() { - m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + m_mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New directory") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New directory"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_dir_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); int rc = mkdir(new_dir_path.characters(), 0777); if (rc < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("mkdir(\"{}\") failed: {}", new_dir_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); } } }); - m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + m_touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { String value; - if (GUI::InputBox::show(window(), value, "Enter name:", "New file") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Enter name:"sv, "New file"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto new_file_path = LexicalPath::canonicalized_path(String::formatted("{}/{}", path(), value)); struct stat st; int rc = stat(new_file_path.characters(), &st); if ((rc < 0 && errno != ENOENT)) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("stat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } if (rc == 0) { - GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("{}: Already exists", new_file_path), "Error"sv, GUI::MessageBox::Type::Error); return; } int fd = creat(new_file_path.characters(), 0666); if (fd < 0) { auto saved_errno = errno; - GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("creat(\"{}\") failed: {}", new_file_path, strerror(saved_errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } rc = close(fd); @@ -588,7 +588,7 @@ void DirectoryView::setup_actions() } }); - m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_open_terminal_action = GUI::Action::create("Open &Terminal Here", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { spawn_terminal(path()); }); @@ -605,23 +605,23 @@ void DirectoryView::setup_actions() window()); m_view_as_icons_action = GUI::Action::create_checkable( - "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Icons", { Mod_Ctrl, KeyCode::Key_1 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/icon-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Icon); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Icon"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv); }, window()); m_view_as_table_action = GUI::Action::create_checkable( - "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Table", { Mod_Ctrl, KeyCode::Key_2 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/table-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Table); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Table"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Table"sv); }, window()); m_view_as_columns_action = GUI::Action::create_checkable( - "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + "View as &Columns", { Mod_Ctrl, KeyCode::Key_3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/columns-view.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { set_view_mode(DirectoryView::ViewMode::Columns); - Config::write_string("FileManager", "DirectoryView", "ViewMode", "Columns"); + Config::write_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Columns"sv); }, window()); diff --git a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp index 51532cad110..2ecbe804453 100644 --- a/Userland/Applications/FileManager/FileOperationProgressWidget.cpp +++ b/Userland/Applications/FileManager/FileOperationProgressWidget.cpp @@ -27,20 +27,20 @@ FileOperationProgressWidget::FileOperationProgressWidget(FileOperation operation auto& button = *find_descendant_of_type_named("button"); auto& file_copy_animation = *find_descendant_of_type_named("file_copy_animation"); - file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif"); + file_copy_animation.load_from_file("/res/graphics/file-flying-animation.gif"sv); file_copy_animation.animate(); auto& source_folder_icon = *find_descendant_of_type_named("source_folder_icon"); - source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"); + source_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv); auto& destination_folder_icon = *find_descendant_of_type_named("destination_folder_icon"); switch (m_operation) { case FileOperation::Delete: - destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png"); + destination_folder_icon.load_from_file("/res/icons/32x32/recycle-bin.png"sv); break; default: - destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"); + destination_folder_icon.load_from_file("/res/icons/32x32/filetype-folder-open.png"sv); break; } @@ -129,7 +129,7 @@ void FileOperationProgressWidget::did_error(StringView message) { // FIXME: Communicate more with the user about errors. close_pipe(); - GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); + GUI::MessageBox::show(window(), String::formatted("An error occurred: {}", message), "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::OK); window()->close(); } diff --git a/Userland/Applications/FileManager/FileUtils.cpp b/Userland/Applications/FileManager/FileUtils.cpp index fdcc66b7dc8..f74fc80a0e4 100644 --- a/Userland/Applications/FileManager/FileUtils.cpp +++ b/Userland/Applications/FileManager/FileUtils.cpp @@ -29,7 +29,7 @@ void delete_paths(Vector const& paths, bool should_confirm, GUI::Window* if (should_confirm) { auto result = GUI::MessageBox::show(parent_window, message, - "Confirm deletion", + "Confirm deletion"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); if (result == GUI::MessageBox::ExecResult::Cancel) @@ -51,17 +51,17 @@ ErrorOr run_file_operation(FileOperation operation, Vector const& TRY(Core::System::dup2(pipe_fds[1], STDOUT_FILENO)); Vector file_operation_args; - file_operation_args.append("/bin/FileOperation"); + file_operation_args.append("/bin/FileOperation"sv); switch (operation) { case FileOperation::Copy: - file_operation_args.append("Copy"); + file_operation_args.append("Copy"sv); break; case FileOperation::Move: - file_operation_args.append("Move"); + file_operation_args.append("Move"sv); break; case FileOperation::Delete: - file_operation_args.append("Delete"); + file_operation_args.append("Delete"sv); break; default: VERIFY_NOT_REACHED(); diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 45a6012f109..2e6e874d76e 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -40,7 +40,7 @@ PropertiesWindow::PropertiesWindow(String const& path, bool disable_rename, Wind set_rect({ 0, 0, 360, 420 }); set_resizable(false); - set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors()); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors()); auto& tab_widget = main_widget.add(); @@ -194,12 +194,12 @@ bool PropertiesWindow::apply_changes() String new_file = make_full_path(new_name).characters(); if (Core::File::exists(new_file)) { - GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error"sv, GUI::MessageBox::Type::Error); return false; } if (rename(make_full_path(m_name).characters(), new_file.characters())) { - GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("Could not rename file: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } @@ -210,7 +210,7 @@ bool PropertiesWindow::apply_changes() if (m_permissions_dirty) { if (chmod(make_full_path(m_name).characters(), m_mode)) { - GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(this, String::formatted("Could not update permissions: {}!", strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return false; } diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp index ff1d45c46d0..5b926e88597 100644 --- a/Userland/Applications/FileManager/main.cpp +++ b/Userland/Applications/FileManager/main.cpp @@ -135,7 +135,7 @@ void do_copy(Vector const& selected_file_paths, FileOperation file_opera StringBuilder copy_text; if (file_operation == FileOperation::Move) { - copy_text.append("#cut\n"); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish + copy_text.append("#cut\n"sv); // This exploits the comment lines in the text/uri-list specification, which might be a bit hackish } for (auto& path : selected_file_paths) { auto url = URL::create_with_file_protocol(path); @@ -186,7 +186,7 @@ void do_create_link(Vector const& selected_file_paths, GUI::Window* wind auto path = selected_file_paths.first(); auto destination = String::formatted("{}/{}", Core::StandardPaths::desktop_directory(), LexicalPath::basename(path)); if (auto result = Core::File::link_file(destination, path); result.is_error()) { - GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager", + GUI::MessageBox::show(window, String::formatted("Could not create desktop shortcut:\n{}", result.error()), "File Manager"sv, GUI::MessageBox::Type::Error); } } @@ -194,7 +194,7 @@ void do_create_link(Vector const& selected_file_paths, GUI::Window* wind void do_create_archive(Vector const& selected_file_paths, GUI::Window* window) { String archive_name; - if (GUI::InputBox::show(window, archive_name, "Enter name:", "Create Archive") != GUI::InputBox::ExecResult::OK) + if (GUI::InputBox::show(window, archive_name, "Enter name:"sv, "Create Archive"sv) != GUI::InputBox::ExecResult::OK) return; auto output_directory_path = LexicalPath(selected_file_paths.first()); @@ -204,11 +204,11 @@ void do_create_archive(Vector const& selected_file_paths, GUI::Window* w path_builder.append("/"); if (archive_name.is_empty()) { path_builder.append(output_directory_path.parent().basename()); - path_builder.append(".zip"); + path_builder.append(".zip"sv); } else { path_builder.append(archive_name); - if (!archive_name.ends_with(".zip")) - path_builder.append(".zip"); + if (!archive_name.ends_with(".zip"sv)) + path_builder.append(".zip"sv); } auto output_path = path_builder.build(); @@ -239,7 +239,7 @@ void do_create_archive(Vector const& selected_file_paths, GUI::Window* w int status; int rc = waitpid(zip_pid, &status, 0); if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - GUI::MessageBox::show(window, "Could not create archive", "Archive Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Could not create archive"sv, "Archive Error"sv, GUI::MessageBox::Type::Error); } } @@ -265,7 +265,7 @@ void do_unzip_archive(Vector const& selected_file_paths, GUI::Window* wi int status; int rc = waitpid(unzip_pid, &status, 0); if (rc < 0 || !WIFEXITED(status) || WEXITSTATUS(status) != 0) - GUI::MessageBox::show(window, "Could not extract archive", "Extract Archive Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Could not extract archive"sv, "Extract Archive Error"sv, GUI::MessageBox::Type::Error); } } @@ -362,7 +362,7 @@ ErrorOr run_in_desktop_mode() auto create_archive_action = GUI::Action::create( "Create &Archive", - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) @@ -411,7 +411,7 @@ ErrorOr run_in_desktop_mode() auto desktop_view_context_menu = TRY(GUI::Menu::try_create("Directory View")); - auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto file_manager_action = GUI::Action::create("Open in File &Manager", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { Desktop::Launcher::open(URL::create_with_file_protocol(directory_view->path())); @@ -424,7 +424,7 @@ ErrorOr run_in_desktop_mode() } }); - auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto open_terminal_action = GUI::Action::create("Open in &Terminal", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { spawn_terminal(directory_view->path()); @@ -438,7 +438,7 @@ ErrorOr run_in_desktop_mode() } }); - auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto display_properties_action = GUI::Action::create("&Display Settings", {}, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { Desktop::Launcher::open(URL::create_with_file_protocol("/bin/DisplaySettings")); }); @@ -488,7 +488,7 @@ ErrorOr run_in_desktop_mode() file_context_menu->add_action(create_archive_action); file_context_menu->add_separator(); - if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) { + if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) { file_context_menu->add_action(unzip_archive_action); file_context_menu->add_separator(); } @@ -514,7 +514,7 @@ ErrorOr run_in_desktop_mode() } } wallpaper_listener; - auto selected_wallpaper = Config::read_string("WindowManager", "Background", "Wallpaper", ""); + auto selected_wallpaper = Config::read_string("WindowManager"sv, "Background"sv, "Wallpaper"sv, ""sv); if (!selected_wallpaper.is_empty()) { auto wallpaper_bitmap = TRY(Gfx::Bitmap::try_load_from_file(selected_wallpaper)); GUI::Desktop::the().set_wallpaper(wallpaper_bitmap, {}); @@ -529,11 +529,11 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& auto window = TRY(GUI::Window::try_create()); window->set_title("File Manager"); - auto left = Config::read_i32("FileManager", "Window", "Left", 150); - auto top = Config::read_i32("FileManager", "Window", "Top", 75); - auto width = Config::read_i32("FileManager", "Window", "Width", 640); - auto height = Config::read_i32("FileManager", "Window", "Height", 480); - auto was_maximized = Config::read_bool("FileManager", "Window", "Maximized", false); + auto left = Config::read_i32("FileManager"sv, "Window"sv, "Left"sv, 150); + auto top = Config::read_i32("FileManager"sv, "Window"sv, "Top"sv, 75); + auto width = Config::read_i32("FileManager"sv, "Window"sv, "Width"sv, 640); + auto height = Config::read_i32("FileManager"sv, "Window"sv, "Height"sv, 480); + auto was_maximized = Config::read_bool("FileManager"sv, "Window"sv, "Maximized"sv, false); auto widget = TRY(window->try_set_main_widget()); @@ -628,7 +628,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& auto directory_view_context_menu = TRY(GUI::Menu::try_create("Directory View")); auto tree_view_directory_context_menu = TRY(GUI::Menu::try_create("Tree View Directory")); - auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto open_parent_directory_action = GUI::Action::create("Open &Parent Directory", { Mod_Alt, Key_Up }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-parent-directory.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->open_parent_directory(); }); @@ -637,7 +637,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& RefPtr layout_statusbar_action; RefPtr layout_folderpane_action; - auto show_toolbar = Config::read_bool("FileManager", "Layout", "ShowToolbar", true); + auto show_toolbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, true); layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) { if (action.is_checked()) { main_toolbar.set_visible(true); @@ -648,12 +648,12 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& toolbar_container.set_visible(false); } show_toolbar = action.is_checked(); - Config::write_bool("FileManager", "Layout", "ShowToolbar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked()); }); layout_toolbar_action->set_checked(show_toolbar); main_toolbar.set_visible(show_toolbar); - auto show_location = Config::read_bool("FileManager", "Layout", "ShowLocationBar", true); + auto show_location = Config::read_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, true); layout_location_action = GUI::Action::create_checkable("&Location Bar", [&](auto& action) { if (action.is_checked()) { breadcrumb_toolbar.set_visible(true); @@ -666,7 +666,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& toolbar_container.set_visible(false); } show_location = action.is_checked(); - Config::write_bool("FileManager", "Layout", "ShowLocationBar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowLocationBar"sv, action.is_checked()); }); layout_location_action->set_checked(show_location); breadcrumb_toolbar.set_visible(show_location); @@ -675,19 +675,19 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& layout_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) { action.is_checked() ? statusbar.set_visible(true) : statusbar.set_visible(false); - Config::write_bool("FileManager", "Layout", "ShowStatusbar", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, action.is_checked()); }); - auto show_statusbar = Config::read_bool("FileManager", "Layout", "ShowStatusbar", true); + auto show_statusbar = Config::read_bool("FileManager"sv, "Layout"sv, "ShowStatusbar"sv, true); layout_statusbar_action->set_checked(show_statusbar); statusbar.set_visible(show_statusbar); layout_folderpane_action = GUI::Action::create_checkable("&Folder Pane", { Mod_Ctrl, Key_P }, [&](auto& action) { action.is_checked() ? tree_view.set_visible(true) : tree_view.set_visible(false); - Config::write_bool("FileManager", "Layout", "ShowFolderPane", action.is_checked()); + Config::write_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, action.is_checked()); }); - auto show_folderpane = Config::read_bool("FileManager", "Layout", "ShowFolderPane", true); + auto show_folderpane = Config::read_bool("FileManager"sv, "Layout"sv, "ShowFolderPane"sv, true); layout_folderpane_action->set_checked(show_folderpane); tree_view.set_visible(show_folderpane); @@ -749,7 +749,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Open in New &Window", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-file-manager.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const& action) { Vector paths; if (action.activator() == tree_view_directory_context_menu) @@ -768,7 +768,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Open in &Terminal", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const& action) { Vector paths; if (action.activator() == tree_view_directory_context_menu) @@ -788,7 +788,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& = GUI::Action::create( "Create Desktop &Shortcut", {}, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-symlink.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) { @@ -801,7 +801,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& auto create_archive_action = GUI::Action::create( "Create &Archive", - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-archive.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { auto paths = directory_view->selected_file_paths(); if (paths.is_empty()) @@ -909,12 +909,12 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& }); focus_dependent_delete_action->set_enabled(false); - auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto mkdir_action = GUI::Action::create("&New Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->mkdir_action().activate(); refresh_tree_view(); }); - auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { + auto touch_action = GUI::Action::create("New &File...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [&](GUI::Action const&) { directory_view->touch_action().activate(); refresh_tree_view(); }); @@ -942,10 +942,10 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& directory_view->set_should_show_dotfiles(action.is_checked()); directories_model->set_should_show_dotfiles(action.is_checked()); refresh_tree_view(); - Config::write_bool("FileManager", "DirectoryView", "ShowDotFiles", action.is_checked()); + Config::write_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, action.is_checked()); }); - auto show_dotfiles = Config::read_bool("FileManager", "DirectoryView", "ShowDotFiles", false); + auto show_dotfiles = Config::read_bool("FileManager"sv, "DirectoryView"sv, "ShowDotFiles"sv, false); directory_view->set_should_show_dotfiles(show_dotfiles); show_dotfiles_action->set_checked(show_dotfiles); @@ -968,7 +968,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& TRY(view_menu->try_add_separator()); TRY(view_menu->try_add_action(show_dotfiles_action)); - auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto go_to_location_action = GUI::Action::create("Go to &Location...", { Mod_Ctrl, Key_L }, Key_F6, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { toolbar_container.set_visible(true); location_toolbar.set_visible(true); breadcrumb_toolbar.set_visible(false); @@ -986,7 +986,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& TRY(go_menu->try_add_action(directory_view->open_terminal_action())); auto help_menu = TRY(window->try_add_menu("&Help")); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager", GUI::Icon::default_icon("app-file-manager"), window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("File Manager"sv, GUI::Icon::default_icon("app-file-manager"sv), window))); (void)TRY(main_toolbar.try_add_action(go_back_action)); (void)TRY(main_toolbar.try_add_action(go_forward_action)); @@ -1113,7 +1113,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& || (!directory_view->current_view().selection().is_empty() && access(directory_view->path().characters(), W_OK) == 0)); }; - auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto directory_open_action = GUI::Action::create("Open", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { directory_view->open(directory_view->selected_file_paths().first()); }); @@ -1180,7 +1180,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& file_context_menu->add_action(create_archive_action); file_context_menu->add_separator(); - if (node.full_path().ends_with(".zip", AK::CaseSensitivity::CaseInsensitive)) { + if (node.full_path().ends_with(".zip"sv, AK::CaseSensitivity::CaseInsensitive)) { file_context_menu->add_action(unzip_archive_action); file_context_menu->add_separator(); } @@ -1243,7 +1243,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& if (auto result = Core::File::copy_file_or_directory(url_to_copy.path(), new_path); result.is_error()) { auto error_message = String::formatted("Could not copy {} into {}:\n {}", url_to_copy.to_string(), new_path, static_cast(result.error())); - GUI::MessageBox::show(window, error_message, "File Manager", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, error_message, "File Manager"sv, GUI::MessageBox::Type::Error); } else { had_accepted_copy = true; } @@ -1288,7 +1288,7 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& window->show(); - directory_view->set_view_mode_from_string(Config::read_string("FileManager", "DirectoryView", "ViewMode", "Icon")); + directory_view->set_view_mode_from_string(Config::read_string("FileManager"sv, "DirectoryView"sv, "ViewMode"sv, "Icon"sv)); if (!entry_focused_on_init.is_empty()) { auto matches = directory_view->current_view().model()->matches(entry_focused_on_init, GUI::Model::MatchesFlag::MatchFull | GUI::Model::MatchesFlag::FirstMatchOnly); @@ -1298,12 +1298,12 @@ ErrorOr run_in_windowed_mode(String const& initial_location, String const& // Write window position to config file on close request. window->on_close_request = [&] { - Config::write_bool("FileManager", "Window", "Maximized", window->is_maximized()); + Config::write_bool("FileManager"sv, "Window"sv, "Maximized"sv, window->is_maximized()); if (!window->is_maximized()) { - Config::write_i32("FileManager", "Window", "Left", window->x()); - Config::write_i32("FileManager", "Window", "Top", window->y()); - Config::write_i32("FileManager", "Window", "Width", window->width()); - Config::write_i32("FileManager", "Window", "Height", window->height()); + Config::write_i32("FileManager"sv, "Window"sv, "Left"sv, window->x()); + Config::write_i32("FileManager"sv, "Window"sv, "Top"sv, window->y()); + Config::write_i32("FileManager"sv, "Window"sv, "Width"sv, window->width()); + Config::write_i32("FileManager"sv, "Window"sv, "Height"sv, window->height()); } return GUI::Window::CloseRequestDecision::Close; }; diff --git a/Userland/Applications/FontEditor/MainWidget.cpp b/Userland/Applications/FontEditor/MainWidget.cpp index 63b34caa110..a9e52ed3b6e 100644 --- a/Userland/Applications/FontEditor/MainWidget.cpp +++ b/Userland/Applications/FontEditor/MainWidget.cpp @@ -45,16 +45,16 @@ namespace FontEditor { static constexpr Array pangrams = { - "quick fox jumps nightly above wizard", - "five quacking zephyrs jolt my wax bed", - "pack my box with five dozen liquor jugs", - "quick brown fox jumps over the lazy dog", - "waxy and quivering jocks fumble the pizza", - "~#:[@_1%]*{$2.3}/4^(5'6\")-&|7+8!=<9,0\\>?;", - "byxfjärmat föl gick på duvshowen", - "         ", - "float Fox.quick(h){ is_brown && it_jumps_over(doges.lazy) }", - "lazy dog" + "quick fox jumps nightly above wizard"sv, + "five quacking zephyrs jolt my wax bed"sv, + "pack my box with five dozen liquor jugs"sv, + "quick brown fox jumps over the lazy dog"sv, + "waxy and quivering jocks fumble the pizza"sv, + "~#:[@_1%]*{$2.3}/4^(5'6\"sv)-&|7+8!=<9,0\\>?;"sv, + "byxfjärmat föl gick på duvshowen"sv, + "         "sv, + "float Fox.quick(h){ is_brown && it_jumps_over(doges.lazy) }"sv, + "lazy dog"sv }; ErrorOr> MainWidget::create_preview_window() @@ -92,7 +92,7 @@ ErrorOr> MainWidget::create_preview_window() ErrorOr MainWidget::create_actions() { - m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png")), [&](auto&) { + m_new_action = GUI::Action::create("&New Font...", { Mod_Ctrl, Key_N }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-font.png"sv)), [&](auto&) { if (!request_close()) return; auto new_font_wizard = NewFontDialog::construct(window()); @@ -115,7 +115,7 @@ ErrorOr MainWidget::create_actions() m_open_action = GUI::CommonActions::make_open_action([&](auto&) { if (!request_close()) return; - Optional open_path = GUI::FilePicker::get_open_filepath(window(), {}, "/res/fonts/"); + Optional open_path = GUI::FilePicker::get_open_filepath(window(), {}, "/res/fonts/"sv); if (!open_path.has_value()) return; open_file(open_path.value()); @@ -175,7 +175,7 @@ ErrorOr MainWidget::create_actions() m_undo_selection->set_size(selection.size()); }); - m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png")), [&](auto&) { + m_open_preview_action = GUI::Action::create("&Preview Font", { Mod_Ctrl, Key_P }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv)), [&](auto&) { if (!m_font_preview_window) { if (auto maybe_window = create_preview_window(); maybe_window.is_error()) warnln("Failed to create preview window: {}", maybe_window.error()); @@ -187,27 +187,27 @@ ErrorOr MainWidget::create_actions() }); m_open_preview_action->set_status_tip("Preview the current font"); - bool show_metadata = Config::read_bool("FontEditor", "Layout", "ShowMetadata", true); + bool show_metadata = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowMetadata"sv, true); set_show_font_metadata(show_metadata); m_show_metadata_action = GUI::Action::create_checkable("Font &Metadata", { Mod_Ctrl, Key_M }, [&](auto& action) { set_show_font_metadata(action.is_checked()); - Config::write_bool("FontEditor", "Layout", "ShowMetadata", action.is_checked()); + Config::write_bool("FontEditor"sv, "Layout"sv, "ShowMetadata"sv, action.is_checked()); }); m_show_metadata_action->set_checked(show_metadata); m_show_metadata_action->set_status_tip("Show or hide metadata about the current font"); - bool show_unicode_blocks = Config::read_bool("FontEditor", "Layout", "ShowUnicodeBlocks", true); + bool show_unicode_blocks = Config::read_bool("FontEditor"sv, "Layout"sv, "ShowUnicodeBlocks"sv, true); set_show_unicode_blocks(show_unicode_blocks); m_show_unicode_blocks_action = GUI::Action::create_checkable("&Unicode Blocks", { Mod_Ctrl, Key_U }, [&](auto& action) { set_show_unicode_blocks(action.is_checked()); - Config::write_bool("FontEditor", "Layout", "ShowUnicodeBlocks", action.is_checked()); + Config::write_bool("FontEditor"sv, "Layout"sv, "ShowUnicodeBlocks"sv, action.is_checked()); }); m_show_unicode_blocks_action->set_checked(show_unicode_blocks); m_show_unicode_blocks_action->set_status_tip("Show or hide the Unicode block list"); - m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png")), [&](auto&) { + m_go_to_glyph_action = GUI::Action::create("&Go to Glyph...", { Mod_Ctrl, Key_G }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv)), [&](auto&) { String input; - if (GUI::InputBox::show(window(), input, "Hexadecimal:", "Go to glyph") == GUI::InputBox::ExecResult::OK && !input.is_empty()) { + if (GUI::InputBox::show(window(), input, "Hexadecimal:"sv, "Go to glyph"sv) == GUI::InputBox::ExecResult::OK && !input.is_empty()) { auto maybe_code_point = AK::StringUtils::convert_to_uint_from_hex(input); if (!maybe_code_point.has_value()) return; @@ -220,17 +220,17 @@ ErrorOr MainWidget::create_actions() }); m_go_to_glyph_action->set_status_tip("Go to the specified code point"); - m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](auto&) { + m_previous_glyph_action = GUI::Action::create("Pre&vious Glyph", { Mod_Alt, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) { m_glyph_map_widget->select_previous_existing_glyph(); }); m_previous_glyph_action->set_status_tip("Seek the previous visible glyph"); - m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](auto&) { + m_next_glyph_action = GUI::Action::create("&Next Glyph", { Mod_Alt, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](auto&) { m_glyph_map_widget->select_next_existing_glyph(); }); m_next_glyph_action->set_status_tip("Seek the next visible glyph"); - i32 scale = Config::read_i32("FontEditor", "GlyphEditor", "Scale", 10); + i32 scale = Config::read_i32("FontEditor"sv, "GlyphEditor"sv, "Scale"sv, 10); set_scale(scale); m_scale_five_action = GUI::Action::create_checkable("500%", { Mod_Ctrl, Key_1 }, [this](auto&) { set_scale_and_save(5); @@ -253,12 +253,12 @@ ErrorOr MainWidget::create_actions() m_glyph_editor_scale_actions.add_action(*m_scale_fifteen_action); m_glyph_editor_scale_actions.set_exclusive(true); - m_paint_glyph_action = GUI::Action::create_checkable("Paint Glyph", { Mod_Ctrl, KeyCode::Key_J }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/pen.png")), [&](auto&) { + m_paint_glyph_action = GUI::Action::create_checkable("Paint Glyph", { Mod_Ctrl, KeyCode::Key_J }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/pen.png"sv)), [&](auto&) { m_glyph_editor_widget->set_mode(GlyphEditorWidget::Paint); }); m_paint_glyph_action->set_checked(true); - m_move_glyph_action = GUI::Action::create_checkable("Move Glyph", { Mod_Ctrl, KeyCode::Key_K }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png")), [&](auto&) { + m_move_glyph_action = GUI::Action::create_checkable("Move Glyph", { Mod_Ctrl, KeyCode::Key_K }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png"sv)), [&](auto&) { m_glyph_editor_widget->set_mode(GlyphEditorWidget::Move); }); @@ -274,15 +274,15 @@ ErrorOr MainWidget::create_actions() m_glyph_editor_widget->rotate_90(GlyphEditorWidget::Clockwise); }); - m_flip_horizontal_action = GUI::Action::create("Flip Horizontally", { Mod_Ctrl | Mod_Shift, Key_Q }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png")), [&](auto&) { + m_flip_horizontal_action = GUI::Action::create("Flip Horizontally", { Mod_Ctrl | Mod_Shift, Key_Q }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv)), [&](auto&) { m_glyph_editor_widget->flip_horizontally(); }); - m_flip_vertical_action = GUI::Action::create("Flip Vertically", { Mod_Ctrl | Mod_Shift, Key_W }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png")), [&](auto&) { + m_flip_vertical_action = GUI::Action::create("Flip Vertically", { Mod_Ctrl | Mod_Shift, Key_W }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv)), [&](auto&) { m_glyph_editor_widget->flip_vertically(); }); - m_copy_text_action = GUI::Action::create("Copy as Te&xt", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png")), [&](auto&) { + m_copy_text_action = GUI::Action::create("Copy as Te&xt", { Mod_Ctrl, Key_T }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv)), [&](auto&) { StringBuilder builder; auto selection = m_glyph_map_widget->selection().normalized(); for (auto code_point = selection.start(); code_point < selection.start() + selection.size(); ++code_point) { @@ -348,7 +348,7 @@ ErrorOr MainWidget::create_models() m_unicode_block_model = GUI::ItemListModel::create(m_unicode_block_list); m_filter_model = TRY(GUI::FilteringProxyModel::create(*m_unicode_block_model)); - m_filter_model->set_filter_term(""); + m_filter_model->set_filter_term(""sv); m_unicode_block_listview = find_descendant_of_type_named("unicode_block_listview"); m_unicode_block_listview->on_selection_change = [this, unicode_blocks] { @@ -658,7 +658,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) TRY(help_menu->try_add_action(GUI::CommonActions::make_help_action([](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/FontEditor.md"), "/bin/Help"); }))); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor")), &window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Font Editor", TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv)), &window))); return {}; } @@ -668,7 +668,7 @@ bool MainWidget::save_file(String const& path) auto saved_font = m_edited_font->masked_character_set(); auto ret_val = saved_font->write_to_file(path); if (!ret_val) { - GUI::MessageBox::show(window(), "The font file could not be saved.", "Save failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "The font file could not be saved."sv, "Save failed"sv, GUI::MessageBox::Type::Error); return false; } m_path = path; @@ -699,7 +699,7 @@ bool MainWidget::open_file(String const& path) auto bitmap_font = Gfx::BitmapFont::load_from_file(path); if (!bitmap_font) { String message = String::formatted("Couldn't load font: {}\n", path); - GUI::MessageBox::show(window(), message, "Font Editor", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), message, "Font Editor"sv, GUI::MessageBox::Type::Error); return false; } auto new_font = bitmap_font->unmasked_character_set(); @@ -748,7 +748,7 @@ void MainWidget::undo() auto glyph = m_undo_selection->restored_active_glyph(); auto glyph_width = edited_font().raw_glyph_width(glyph); if (glyph < m_range.first || glyph > m_range.last) - m_search_textbox->set_text(""); + m_search_textbox->set_text(""sv); deferred_invoke([this, glyph] { auto start = m_undo_selection->restored_start(); @@ -778,7 +778,7 @@ void MainWidget::redo() auto glyph = m_undo_selection->restored_active_glyph(); auto glyph_width = edited_font().raw_glyph_width(glyph); if (glyph < m_range.first || glyph > m_range.last) - m_search_textbox->set_text(""); + m_search_textbox->set_text(""sv); deferred_invoke([this, glyph] { auto start = m_undo_selection->restored_start(); @@ -818,10 +818,10 @@ void MainWidget::update_title() { StringBuilder title; if (m_path.is_empty()) - title.append("Untitled"); + title.append("Untitled"sv); else title.append(m_path); - title.append("[*] - Font Editor"); + title.append("[*] - Font Editor"sv); window()->set_title(title.to_string()); } @@ -894,7 +894,7 @@ void MainWidget::set_scale(i32 scale) void MainWidget::set_scale_and_save(i32 scale) { set_scale(scale); - Config::write_i32("FontEditor", "GlyphEditor", "Scale", scale); + Config::write_i32("FontEditor"sv, "GlyphEditor"sv, "Scale"sv, scale); m_glyph_editor_widget->set_fixed_size(m_glyph_editor_widget->preferred_width(), m_glyph_editor_widget->preferred_height()); } @@ -926,7 +926,7 @@ void MainWidget::cut_selected_glyphs() void MainWidget::paste_glyphs() { auto [data, mime_type, metadata] = GUI::Clipboard::the().fetch_data_and_type(); - if (!mime_type.starts_with("glyph/")) + if (!mime_type.starts_with("glyph/"sv)) return; auto glyph_count = metadata.get("count").value().to_uint().value_or(0); diff --git a/Userland/Applications/FontEditor/main.cpp b/Userland/Applications/FontEditor/main.cpp index baebc638648..b89953e7763 100644 --- a/Userland/Applications/FontEditor/main.cpp +++ b/Userland/Applications/FontEditor/main.cpp @@ -36,7 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "The font file for editing.", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-font-editor")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-font-editor"sv)); auto window = TRY(GUI::Window::try_create()); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/Help/MainWidget.cpp b/Userland/Applications/Help/MainWidget.cpp index 97e534b8382..82d830498d4 100644 --- a/Userland/Applications/Help/MainWidget.cpp +++ b/Userland/Applications/Help/MainWidget.cpp @@ -94,7 +94,7 @@ MainWidget::MainWidget() m_web_view->on_link_click = [this](auto& url, auto&, unsigned) { if (url.protocol() == "file") { auto path = url.path(); - if (!path.starts_with("/usr/share/man/")) { + if (!path.starts_with("/usr/share/man/"sv)) { open_external(url); return; } @@ -181,7 +181,7 @@ void MainWidget::set_start_page(StringView start_page, u32 section) m_history.push(path); open_page(path); set_start_page = true; - } else if (URL url = URL::create_with_url_or_path(start_page); url.is_valid() && url.path().ends_with(".md")) { + } else if (URL url = URL::create_with_url_or_path(start_page); url.is_valid() && url.path().ends_with(".md"sv)) { // > Help [/path/to/documentation/file.md] m_history.push(url.path()); open_page(url.path()); @@ -241,11 +241,11 @@ ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) TRY(go_menu->try_add_action(*m_go_home_action)); auto help_menu = TRY(window.try_add_menu("&Help")); - TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png")), [&](auto&) { + TRY(help_menu->try_add_action(GUI::Action::create("&Contents", { Key_F1 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png"sv)), [&](auto&) { String path = "/usr/share/man/man1/Help.md"; open_page(path); }))); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help")), &window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Help", TRY(GUI::Icon::try_create_default_icon("app-help"sv)), &window))); m_context_menu = TRY(GUI::Menu::try_create()); TRY(m_context_menu->try_add_action(*m_go_back_action)); @@ -259,7 +259,7 @@ ErrorOr MainWidget::initialize_fallibles(GUI::Window& window) m_browse_view->set_model(*m_manual_model); m_filter_model = TRY(GUI::FilteringProxyModel::create(*m_manual_model)); m_search_view->set_model(*m_filter_model); - m_filter_model->set_filter_term(""); + m_filter_model->set_filter_term(""sv); return {}; } @@ -287,7 +287,7 @@ void MainWidget::open_url(URL const& url) void MainWidget::open_external(URL const& url) { if (!Desktop::Launcher::open(url)) - GUI::MessageBox::show(window(), String::formatted("The link to '{}' could not be opened.", url), "Failed to open link", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("The link to '{}' could not be opened.", url), "Failed to open link"sv, GUI::MessageBox::Type::Error); } void MainWidget::open_page(String const& path) diff --git a/Userland/Applications/Help/ManualModel.cpp b/Userland/Applications/Help/ManualModel.cpp index 7f35f565d57..619086bc047 100644 --- a/Userland/Applications/Help/ManualModel.cpp +++ b/Userland/Applications/Help/ManualModel.cpp @@ -23,9 +23,9 @@ static ManualSectionNode s_sections[] = { ManualModel::ManualModel() { - m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors()); - m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors()); - m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors()); + m_section_open_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); + m_section_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv).release_value_but_fixme_should_propagate_errors()); + m_page_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors()); } Optional ManualModel::index_from_path(StringView path) const diff --git a/Userland/Applications/Help/main.cpp b/Userland/Applications/Help/main.cpp index 4dbb1741f0a..e91471d70b8 100644 --- a/Userland/Applications/Help/main.cpp +++ b/Userland/Applications/Help/main.cpp @@ -77,7 +77,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } }); args_parser.parse(arguments); - auto app_icon = GUI::Icon::default_icon("app-help"); + auto app_icon = GUI::Icon::default_icon("app-help"sv); auto window = TRY(GUI::Window::try_create()); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/HexEditor/FindDialog.cpp b/Userland/Applications/HexEditor/FindDialog.cpp index 03b8b7fd1f5..9c3c73ed433 100644 --- a/Userland/Applications/HexEditor/FindDialog.cpp +++ b/Userland/Applications/HexEditor/FindDialog.cpp @@ -26,8 +26,8 @@ struct Option { static constexpr Array options = { { - { "ASCII String", OPTION_ASCII_STRING, true, true }, - { "Hex value", OPTION_HEX_VALUE, true, false }, + { "ASCII String"sv, OPTION_ASCII_STRING, true, true }, + { "Hex value"sv, OPTION_HEX_VALUE, true, false }, } }; @@ -79,7 +79,7 @@ Result FindDialog::process_input(String text_value, OptionId } case OPTION_HEX_VALUE: { - auto decoded = decode_hex(text_value.replace(" ", "", ReplaceMode::All)); + auto decoded = decode_hex(text_value.replace(" "sv, ""sv, ReplaceMode::All)); if (decoded.is_error()) return String::formatted("Input is invalid: {}", decoded.error().string_literal()); diff --git a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp index f24428b14e7..d22f861b236 100644 --- a/Userland/Applications/HexEditor/GoToOffsetDialog.cpp +++ b/Userland/Applications/HexEditor/GoToOffsetDialog.cpp @@ -126,9 +126,9 @@ GoToOffsetDialog::GoToOffsetDialog() m_text_editor->on_change = [this]() { auto text = m_text_editor->text(); - if (text.starts_with("0x")) { + if (text.starts_with("0x"sv)) { m_offset_type_box->set_selected_index(1); - m_text_editor->set_text(text.replace("0x", "", ReplaceMode::FirstOnly)); + m_text_editor->set_text(text.replace("0x"sv, ""sv, ReplaceMode::FirstOnly)); } update_statusbar(); }; diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index c76504e3f4e..0233c4e388e 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -194,17 +194,17 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code() StringBuilder output_string_builder; output_string_builder.appendff("unsigned char raw_data[{}] = {{\n", m_selection_end - m_selection_start); - output_string_builder.append(" "); + output_string_builder.append(" "sv); for (size_t i = m_selection_start, j = 1; i < m_selection_end; i++, j++) { output_string_builder.appendff("{:#02X}", m_document->get(i).value); if (i >= m_selection_end - 1) continue; if ((j % 12) == 0) - output_string_builder.append(",\n "); + output_string_builder.append(",\n "sv); else - output_string_builder.append(", "); + output_string_builder.append(", "sv); } - output_string_builder.append("\n};\n"); + output_string_builder.append("\n};\n"sv); GUI::Clipboard::the().set_plain_text(output_string_builder.to_string()); return true; diff --git a/Userland/Applications/HexEditor/HexEditorWidget.cpp b/Userland/Applications/HexEditor/HexEditorWidget.cpp index 72077951f66..bba7af05a21 100644 --- a/Userland/Applications/HexEditor/HexEditorWidget.cpp +++ b/Userland/Applications/HexEditor/HexEditorWidget.cpp @@ -92,19 +92,19 @@ HexEditorWidget::HexEditorWidget() m_editor->update(); }; - m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { + m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { String value; - if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:", "New file size") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (request_close() && GUI::InputBox::show(window(), value, "Enter new file size:"sv, "New file size"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto file_size = value.to_int(); if (file_size.has_value() && file_size.value() > 0) { window()->set_modified(false); if (!m_editor->open_new_file(file_size.value())) { - GUI::MessageBox::show(window(), "Entered file size is too large.", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Entered file size is too large."sv, "Error"sv, GUI::MessageBox::Type::Error); return; } set_path({}); } else { - GUI::MessageBox::show(window(), "Invalid file size entered.", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Invalid file size entered."sv, "Error"sv, GUI::MessageBox::Type::Error); } } }); @@ -125,7 +125,7 @@ HexEditorWidget::HexEditorWidget() return m_save_as_action->activate(); if (!m_editor->save()) { - GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); } else { window()->set_modified(false); m_editor->update(); @@ -139,7 +139,7 @@ HexEditorWidget::HexEditorWidget() return; auto file = response.release_value(); if (!m_editor->save_as(file)) { - GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -148,7 +148,7 @@ HexEditorWidget::HexEditorWidget() dbgln("Wrote document to {}", file->filename()); }); - m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + m_find_action = GUI::Action::create("&Find", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { auto old_buffer = m_search_buffer; bool find_all = false; if (FindDialog::show(window(), m_search_text, m_search_buffer, find_all) == GUI::InputBox::ExecResult::OK) { @@ -158,7 +158,7 @@ HexEditorWidget::HexEditorWidget() m_search_results->update(); if (matches.is_empty()) { - GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning); return; } @@ -174,7 +174,7 @@ HexEditorWidget::HexEditorWidget() auto result = m_editor->find_and_highlight(m_search_buffer, same_buffers ? last_found_index() : 0); if (!result.has_value()) { - GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), String::formatted("Pattern \"{}\" not found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning); return; } @@ -185,7 +185,7 @@ HexEditorWidget::HexEditorWidget() } }); - m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { + m_goto_offset_action = GUI::Action::create("&Go to Offset ...", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-to.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { int new_offset; auto result = GoToOffsetDialog::show( window(), @@ -201,31 +201,31 @@ HexEditorWidget::HexEditorWidget() m_layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) { m_toolbar_container->set_visible(action.is_checked()); - Config::write_bool("HexEditor", "Layout", "ShowToolbar", action.is_checked()); + Config::write_bool("HexEditor"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked()); }); m_layout_search_results_action = GUI::Action::create_checkable("&Search Results", [&](auto& action) { set_search_results_visible(action.is_checked()); }); - m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hex.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + m_copy_hex_action = GUI::Action::create("Copy &Hex", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hex.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard(); }); m_copy_hex_action->set_enabled(false); - m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + m_copy_text_action = GUI::Action::create("Copy &Text", { Mod_Ctrl | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { m_editor->copy_selected_text_to_clipboard(); }); m_copy_text_action->set_enabled(false); - m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/c.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + m_copy_as_c_code_action = GUI::Action::create("Copy as &C Code", { Mod_Alt | Mod_Shift, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/c.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { m_editor->copy_selected_hex_to_clipboard_as_c_code(); }); m_copy_as_c_code_action->set_enabled(false); m_fill_selection_action = GUI::Action::create("Fill &Selection...", { Mod_Ctrl, Key_B }, [&](const GUI::Action&) { String value; - if (GUI::InputBox::show(window(), value, "Fill byte (hex):", "Fill Selection") == GUI::InputBox::ExecResult::OK && !value.is_empty()) { + if (GUI::InputBox::show(window(), value, "Fill byte (hex):"sv, "Fill Selection"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) { auto fill_byte = strtol(value.characters(), nullptr, 16); m_editor->fill_selection(fill_byte); } @@ -386,29 +386,29 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) edit_menu.add_action(*m_copy_as_c_code_action); edit_menu.add_separator(); edit_menu.add_action(*m_find_action); - edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Find &Next", { Mod_None, Key_F3 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { if (m_search_text.is_empty() || m_search_buffer.is_empty()) { - GUI::MessageBox::show(&window, "Nothing to search for", "Not found", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(&window, "Nothing to search for"sv, "Not found"sv, GUI::MessageBox::Type::Warning); return; } auto result = m_editor->find_and_highlight(m_search_buffer, last_found_index()); if (!result.has_value()) { - GUI::MessageBox::show(&window, String::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not found", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(&window, String::formatted("No more matches for \"{}\" found in this file", m_search_text), "Not found"sv, GUI::MessageBox::Type::Warning); return; } m_editor->update(); m_last_found_index = result.value(); })); - edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + edit_menu.add_action(GUI::Action::create("Find All &Strings", { Mod_Ctrl | Mod_Shift, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { int min_length = 4; auto matches = m_editor->find_all_strings(min_length); m_search_results->set_model(*new SearchResultsModel(move(matches))); m_search_results->update(); if (matches.is_empty()) { - GUI::MessageBox::show(&window, "No strings found in this file", "Not found", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(&window, "No strings found in this file"sv, "Not found"sv, GUI::MessageBox::Type::Warning); return; } @@ -420,7 +420,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) auto& view_menu = window.add_menu("&View"); - auto show_toolbar = Config::read_bool("HexEditor", "Layout", "ShowToolbar", true); + auto show_toolbar = Config::read_bool("HexEditor"sv, "Layout"sv, "ShowToolbar"sv, true); m_layout_toolbar_action->set_checked(show_toolbar); m_toolbar_container->set_visible(show_toolbar); view_menu.add_action(*m_layout_toolbar_action); @@ -428,7 +428,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) view_menu.add_action(*m_layout_value_inspector_action); view_menu.add_separator(); - auto bytes_per_row = Config::read_i32("HexEditor", "Layout", "BytesPerRow", 16); + auto bytes_per_row = Config::read_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, 16); m_editor->set_bytes_per_row(bytes_per_row); m_editor->update(); @@ -438,7 +438,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) auto action = GUI::Action::create_checkable(String::number(i), [this, i](auto&) { m_editor->set_bytes_per_row(i); m_editor->update(); - Config::write_i32("HexEditor", "Layout", "BytesPerRow", i); + Config::write_i32("HexEditor"sv, "Layout"sv, "BytesPerRow"sv, i); }); m_bytes_per_row_actions.add_action(action); bytes_per_row_menu.add_action(action); @@ -466,7 +466,7 @@ void HexEditorWidget::initialize_menubar(GUI::Window& window) little_endian_mode->set_checked(true); auto& help_menu = window.add_menu("&Help"); - help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("Hex Editor", GUI::Icon::default_icon("app-hex-editor"sv), &window)); } void HexEditorWidget::set_path(StringView path) @@ -488,10 +488,10 @@ void HexEditorWidget::update_title() { StringBuilder builder; if (m_path.is_empty()) - builder.append("Untitled"); + builder.append("Untitled"sv); else builder.append(m_path); - builder.append("[*] - Hex Editor"); + builder.append("[*] - Hex Editor"sv); window()->set_title(builder.to_string()); } diff --git a/Userland/Applications/HexEditor/main.cpp b/Userland/Applications/HexEditor/main.cpp index df42d6223d1..63c77a1c086 100644 --- a/Userland/Applications/HexEditor/main.cpp +++ b/Userland/Applications/HexEditor/main.cpp @@ -25,7 +25,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Config::pledge_domain("HexEditor"); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hex-editor"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("Hex Editor"); diff --git a/Userland/Applications/ImageViewer/ViewWidget.cpp b/Userland/Applications/ImageViewer/ViewWidget.cpp index 0a1dfc7c4ef..0ca9b8d9a85 100644 --- a/Userland/Applications/ImageViewer/ViewWidget.cpp +++ b/Userland/Applications/ImageViewer/ViewWidget.cpp @@ -154,7 +154,7 @@ void ViewWidget::mouseup_event(GUI::MouseEvent& event) void ViewWidget::load_from_file(String const& path) { auto show_error = [&] { - GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Failed to open {}", path), "Cannot open image"sv, GUI::MessageBox::Type::Error); }; auto file_or_error = Core::MappedFile::map(path); diff --git a/Userland/Applications/ImageViewer/main.cpp b/Userland/Applications/ImageViewer/main.cpp index 555b96c4a89..0fa847cd459 100644 --- a/Userland/Applications/ImageViewer/main.cpp +++ b/Userland/Applications/ImageViewer/main.cpp @@ -43,7 +43,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Desktop::Launcher::add_allowed_handler_with_only_specific_urls("/bin/Help", { URL::create_with_file_protocol("/usr/share/man/man1/ImageViewer.md") })); TRY(Desktop::Launcher::seal_allowlist()); - auto app_icon = GUI::Icon::default_icon("filetype-image"); + auto app_icon = GUI::Icon::default_icon("filetype-image"sv); char const* path = nullptr; Core::ArgsParser args_parser; @@ -124,7 +124,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto msgbox_result = GUI::MessageBox::show(window, String::formatted("Are you sure you want to delete {}?", path), - "Confirm deletion", + "Confirm deletion"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); @@ -135,7 +135,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (unlinked_or_error.is_error()) { GUI::MessageBox::show(window, String::formatted("unlink({}) failed: {}", path, unlinked_or_error.error()), - "Delete failed", + "Delete failed"sv, GUI::MessageBox::Type::Error); return; @@ -157,42 +157,42 @@ ErrorOr serenity_main(Main::Arguments arguments) widget->rotate(Gfx::RotationDirection::Clockwise); }); - auto vertical_flip_action = GUI::Action::create("Flip &Vertically", { Mod_None, Key_V }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png")), + auto vertical_flip_action = GUI::Action::create("Flip &Vertically", { Mod_None, Key_V }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv)), [&](auto&) { widget->flip(Gfx::Orientation::Vertical); }); - auto horizontal_flip_action = GUI::Action::create("Flip &Horizontally", { Mod_None, Key_H }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png")), + auto horizontal_flip_action = GUI::Action::create("Flip &Horizontally", { Mod_None, Key_H }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv)), [&](auto&) { widget->flip(Gfx::Orientation::Horizontal); }); - auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png")), + auto desktop_wallpaper_action = GUI::Action::create("Set as Desktop &Wallpaper", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-display-settings.png"sv)), [&](auto&) { if (!GUI::Desktop::the().set_wallpaper(widget->bitmap(), widget->path())) { GUI::MessageBox::show(window, String::formatted("set_wallpaper({}) failed", widget->path()), - "Could not set wallpaper", + "Could not set wallpaper"sv, GUI::MessageBox::Type::Error); } }); - auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png")), + auto go_first_action = GUI::Action::create("&Go to First", { Mod_None, Key_Home }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-first.png"sv)), [&](auto&) { widget->navigate(ViewWidget::Directions::First); }); - auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), + auto go_back_action = GUI::Action::create("Go &Back", { Mod_None, Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) { widget->navigate(ViewWidget::Directions::Back); }); - auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), + auto go_forward_action = GUI::Action::create("Go &Forward", { Mod_None, Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](auto&) { widget->navigate(ViewWidget::Directions::Forward); }); - auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png")), + auto go_last_action = GUI::Action::create("Go to &Last", { Mod_None, Key_End }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv)), [&](auto&) { widget->navigate(ViewWidget::Directions::Last); }); diff --git a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp index 7b17e604e8a..54039fda5b7 100644 --- a/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp +++ b/Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp @@ -58,7 +58,7 @@ void KeyboardMapperWidget::create_frame() tmp_button.on_click = [this, &tmp_button]() { String value; - if (GUI::InputBox::show(window(), value, "New Character:", "Select Character") == GUI::InputBox::ExecResult::OK) { + if (GUI::InputBox::show(window(), value, "New Character:"sv, "Select Character"sv) == GUI::InputBox::ExecResult::OK) { int i = m_keys.find_first_index(&tmp_button).value_or(0); VERIFY(i > 0); @@ -90,11 +90,11 @@ void KeyboardMapperWidget::create_frame() m_map_group->set_layout(); m_map_group->set_fixed_width(450); - add_map_radio_button("map", "Default"); - add_map_radio_button("shift_map", "Shift"); - add_map_radio_button("altgr_map", "AltGr"); - add_map_radio_button("alt_map", "Alt"); - add_map_radio_button("shift_altgr_map", "Shift+AltGr"); + add_map_radio_button("map"sv, "Default"sv); + add_map_radio_button("shift_map"sv, "Shift"sv); + add_map_radio_button("altgr_map"sv, "AltGr"sv); + add_map_radio_button("alt_map"sv, "Alt"sv); + add_map_radio_button("shift_altgr_map"sv, "Shift+AltGr"sv); bottom_widget.layout()->add_spacer(); } @@ -257,7 +257,7 @@ void KeyboardMapperWidget::update_window_title() { StringBuilder sb; sb.append(m_filename); - sb.append("[*] - Keyboard Mapper"); + sb.append("[*] - Keyboard Mapper"sv); window()->set_title(sb.to_string()); } diff --git a/Userland/Applications/KeyboardMapper/main.cpp b/Userland/Applications/KeyboardMapper/main.cpp index c421aec6c0f..7e3aa1d1335 100644 --- a/Userland/Applications/KeyboardMapper/main.cpp +++ b/Userland/Applications/KeyboardMapper/main.cpp @@ -29,7 +29,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio getkeymap thread rpath cpath wpath recvfd sendfd")); - auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper"); + auto app_icon = GUI::Icon::default_icon("app-keyboard-mapper"sv); auto window = GUI::Window::construct(); window->set_title("Keyboard Mapper"); @@ -50,7 +50,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!keyboard_mapper_widget->request_close()) return; - Optional path = GUI::FilePicker::get_open_filepath(window, "Open", "/res/keymaps/"); + Optional path = GUI::FilePicker::get_open_filepath(window, "Open"sv, "/res/keymaps/"sv); if (!path.has_value()) return; diff --git a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp index 794f78ac04c..05136390237 100644 --- a/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp +++ b/Userland/Applications/KeyboardSettings/KeyboardSettingsWidget.cpp @@ -62,13 +62,13 @@ private: Core::DirIterator iterator("/res/keymaps/", Core::DirIterator::Flags::SkipDots); if (iterator.has_error()) { - GUI::MessageBox::show(nullptr, String::formatted("Error on reading mapping file list: {}", iterator.error_string()), "Keyboard settings", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, String::formatted("Error on reading mapping file list: {}", iterator.error_string()), "Keyboard settings"sv, GUI::MessageBox::Type::Error); GUI::Application::the()->quit(-1); } while (iterator.has_next()) { auto name = iterator.next_path(); - auto basename = name.replace(".json", "", ReplaceMode::FirstOnly); + auto basename = name.replace(".json"sv, ""sv, ReplaceMode::FirstOnly); if (!selected_keymaps.find(basename).is_end()) continue; m_character_map_files.append(basename); @@ -160,8 +160,8 @@ KeyboardSettingsWidget::KeyboardSettingsWidget() auto json = JsonValue::from_string(proc_keymap->read_all()).release_value_but_fixme_should_propagate_errors(); auto const& keymap_object = json.as_object(); - VERIFY(keymap_object.has("keymap")); - m_initial_active_keymap = keymap_object.get("keymap").to_string(); + VERIFY(keymap_object.has("keymap"sv)); + m_initial_active_keymap = keymap_object.get("keymap"sv).to_string(); dbgln("KeyboardSettings thinks the current keymap is: {}", m_initial_active_keymap); auto mapper_config(Core::ConfigFile::open("/etc/Keyboard.ini").release_value_but_fixme_should_propagate_errors()); @@ -247,7 +247,7 @@ KeyboardSettingsWidget::KeyboardSettingsWidget() }; m_num_lock_checkbox = find_descendant_of_type_named("num_lock_checkbox"); - m_num_lock_checkbox->set_checked(Config::read_bool("KeyboardSettings", "StartupEnable", "NumLock", true)); + m_num_lock_checkbox->set_checked(Config::read_bool("KeyboardSettings"sv, "StartupEnable"sv, "NumLock"sv, true)); m_num_lock_checkbox->on_checked = [&](auto) { set_modified(true); }; @@ -277,11 +277,11 @@ void KeyboardSettingsWidget::apply_settings() m_initial_keymap_list.append(keymap); } m_initial_active_keymap = m_keymaps_list_model.active_keymap(); - Config::write_bool("KeyboardSettings", "StartupEnable", "NumLock", m_num_lock_checkbox->is_checked()); + Config::write_bool("KeyboardSettings"sv, "StartupEnable"sv, "NumLock"sv, m_num_lock_checkbox->is_checked()); } void KeyboardSettingsWidget::set_keymaps(Vector const& keymaps, String const& active_keymap) { auto keymaps_string = String::join(',', keymaps); - GUI::Process::spawn_or_show_error(window(), "/bin/keymap", Array { "-s", keymaps_string.characters(), "-m", active_keymap.characters() }); + GUI::Process::spawn_or_show_error(window(), "/bin/keymap"sv, Array { "-s", keymaps_string.characters(), "-m", active_keymap.characters() }); } diff --git a/Userland/Applications/KeyboardSettings/main.cpp b/Userland/Applications/KeyboardSettings/main.cpp index 2315ba15f3f..4433c0e35a2 100644 --- a/Userland/Applications/KeyboardSettings/main.cpp +++ b/Userland/Applications/KeyboardSettings/main.cpp @@ -33,11 +33,11 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/etc/Keyboard.ini", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-keyboard-settings"); + auto app_icon = GUI::Icon::default_icon("app-keyboard-settings"sv); auto window = TRY(GUI::SettingsWindow::create("Keyboard Settings")); window->set_icon(app_icon.bitmap_for_size(16)); - auto keyboard_settings_widget = TRY(window->add_tab("Keyboard", "keyboard")); + auto keyboard_settings_widget = TRY(window->add_tab("Keyboard"sv, "keyboard"sv)); window->set_active_tab(selected_tab); window->on_active_window_change = [&](bool is_active_window) { diff --git a/Userland/Applications/Magnifier/main.cpp b/Userland/Applications/Magnifier/main.cpp index ad93313ad11..47bf2926ce2 100644 --- a/Userland/Applications/Magnifier/main.cpp +++ b/Userland/Applications/Magnifier/main.cpp @@ -24,7 +24,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-magnifier"); + auto app_icon = GUI::Icon::default_icon("app-magnifier"sv); // 4px on each side for padding constexpr int window_dimensions = 200 + 4 + 4; @@ -78,13 +78,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto timeline_menu = TRY(window->try_add_menu("&Timeline")); auto previous_frame_action = GUI::Action::create( - "&Previous frame", { Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png")), [&](auto&) { + "&Previous frame", { Key_Left }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv)), [&](auto&) { pause_action->set_checked(true); magnifier->pause_capture(true); magnifier->display_previous_frame(); }); auto next_frame_action = GUI::Action::create( - "&Next frame", { Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png")), [&](auto&) { + "&Next frame", { Key_Right }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv)), [&](auto&) { pause_action->set_checked(true); magnifier->pause_capture(true); magnifier->display_next_frame(); diff --git a/Userland/Applications/Mail/MailWidget.cpp b/Userland/Applications/Mail/MailWidget.cpp index 1b37ee986b9..82fb72b7e65 100644 --- a/Userland/Applications/Mail/MailWidget.cpp +++ b/Userland/Applications/Mail/MailWidget.cpp @@ -44,7 +44,7 @@ MailWidget::MailWidget() GUI::MessageBox::show( window(), String::formatted("The link to '{}' could not be opened.", url), - "Failed to open link", + "Failed to open link"sv, GUI::MessageBox::Type::Error); } }; @@ -98,28 +98,28 @@ MailWidget::MailWidget() bool MailWidget::connect_and_login() { - auto server = Config::read_string("Mail", "Connection", "Server", {}); + auto server = Config::read_string("Mail"sv, "Connection"sv, "Server"sv, {}); if (server.is_empty()) { - auto result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?", "Error", GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); + auto result = GUI::MessageBox::show(window(), "Mail has no servers configured. Do you want configure them now?"sv, "Error"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); if (result == GUI::MessageBox::ExecResult::Yes) Desktop::Launcher::open(URL::create_with_file_protocol("/bin/MailSettings")); return false; } // Assume TLS by default, which is on port 993. - auto port = Config::read_i32("Mail", "Connection", "Port", 993); - auto tls = Config::read_bool("Mail", "Connection", "TLS", true); + auto port = Config::read_i32("Mail"sv, "Connection"sv, "Port"sv, 993); + auto tls = Config::read_bool("Mail"sv, "Connection"sv, "TLS"sv, true); - auto username = Config::read_string("Mail", "User", "Username", {}); + auto username = Config::read_string("Mail"sv, "User"sv, "Username"sv, {}); if (username.is_empty()) { - GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information."); + GUI::MessageBox::show_error(window(), "Mail has no username configured. Refer to the Mail(1) man page for more information."sv); return false; } - auto password = Config::read_string("Mail", "User", "Password", {}); + auto password = Config::read_string("Mail"sv, "User"sv, "Password"sv, {}); while (password.is_empty()) { - if (GUI::PasswordInputDialog::show(window(), password, "Login", server, username) != GUI::Dialog::ExecResult::OK) + if (GUI::PasswordInputDialog::show(window(), password, "Login"sv, server, username) != GUI::Dialog::ExecResult::OK) return false; } @@ -142,7 +142,7 @@ bool MailWidget::connect_and_login() return false; } - response = m_imap_client->list("", "*")->await().release_value(); + response = m_imap_client->list(""sv, "*"sv)->await().release_value(); if (response.status() != IMAP::ResponseStatus::OK) { dbgln("Failed to retrieve mailboxes. The server says: '{}'", response.response_text()); @@ -171,7 +171,7 @@ void MailWidget::on_window_close() IMAP::MultiPartBodyStructureData const* MailWidget::look_for_alternative_body_structure(IMAP::MultiPartBodyStructureData const& current_body_structure, Vector& position_stack) const { - if (current_body_structure.media_type.equals_ignoring_case("ALTERNATIVE")) + if (current_body_structure.media_type.equals_ignoring_case("ALTERNATIVE"sv)) return ¤t_body_structure; u32 structure_index = 1; @@ -227,7 +227,7 @@ Vector MailWidget::get_alternatives(IMAP::MultiPartBody bool MailWidget::is_supported_alternative(Alternative const& alternative) const { - return alternative.body_structure.type.equals_ignoring_case("text") && (alternative.body_structure.subtype.equals_ignoring_case("plain") || alternative.body_structure.subtype.equals_ignoring_case("html")); + return alternative.body_structure.type.equals_ignoring_case("text"sv) && (alternative.body_structure.subtype.equals_ignoring_case("plain"sv) || alternative.body_structure.subtype.equals_ignoring_case("html"sv)); } void MailWidget::selected_mailbox() @@ -351,7 +351,7 @@ void MailWidget::selected_mailbox() }; auto& subject_iterator_value = subject_iterator->get<1>().value(); - auto subject_index = subject_iterator_value.find("Subject:"); + auto subject_index = subject_iterator_value.find("Subject:"sv); String subject; if (subject_index.has_value()) { auto potential_subject = subject_iterator_value.substring(subject_index.value()); @@ -363,7 +363,7 @@ void MailWidget::selected_mailbox() subject = "(no subject)"; auto& from_iterator_value = from_iterator->get<1>().value(); - auto from_index = from_iterator_value.find("From:"); + auto from_index = from_iterator_value.find("From:"sv); VERIFY(from_index.has_value()); auto potential_from = from_iterator_value.substring(from_index.value()); auto from_parts = potential_from.split_limit(':', 2); @@ -419,7 +419,7 @@ void MailWidget::selected_email_to_load() auto alternatives = get_alternatives(data); if (alternatives.is_empty()) { dbgln("No alternatives. The server said: '{}'", fetch_response.response_text()); - GUI::MessageBox::show_error(window(), "The server sent no message to display."); + GUI::MessageBox::show_error(window(), "The server sent no message to display."sv); return; } @@ -430,7 +430,7 @@ void MailWidget::selected_email_to_load() }); if (!chosen_alternative.has_value()) { - GUI::MessageBox::show(window(), "Displaying this type of e-mail is currently unsupported.", "Unsupported", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), "Displaying this type of e-mail is currently unsupported."sv, "Unsupported"sv, GUI::MessageBox::Type::Information); return; } @@ -469,14 +469,14 @@ void MailWidget::selected_email_to_load() if (fetch_data.is_empty()) { dbgln("The server sent no fetch data."); - GUI::MessageBox::show_error(window(), "The server sent no data."); + GUI::MessageBox::show_error(window(), "The server sent no data."sv); return; } auto& fetch_response_data = fetch_data.last().get(); if (!fetch_response_data.contains_response_type(IMAP::FetchResponseType::Body)) { - GUI::MessageBox::show_error(window(), "The server sent no body."); + GUI::MessageBox::show_error(window(), "The server sent no body."sv); return; } @@ -493,21 +493,21 @@ void MailWidget::selected_email_to_load() // FIXME: String uses char internally, so 8bit shouldn't be stored in it. // However, it works for now. - if (selected_alternative_encoding.equals_ignoring_case("7bit") || selected_alternative_encoding.equals_ignoring_case("8bit")) { + if (selected_alternative_encoding.equals_ignoring_case("7bit"sv) || selected_alternative_encoding.equals_ignoring_case("8bit"sv)) { decoded_data = encoded_data; - } else if (selected_alternative_encoding.equals_ignoring_case("base64")) { + } else if (selected_alternative_encoding.equals_ignoring_case("base64"sv)) { auto decoded_base64 = decode_base64(encoded_data); if (!decoded_base64.is_error()) decoded_data = decoded_base64.release_value(); - } else if (selected_alternative_encoding.equals_ignoring_case("quoted-printable")) { + } else if (selected_alternative_encoding.equals_ignoring_case("quoted-printable"sv)) { decoded_data = IMAP::decode_quoted_printable(encoded_data); } else { dbgln("Mail: Unimplemented decoder for encoding: {}", selected_alternative_encoding); - GUI::MessageBox::show(window(), String::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), String::formatted("The e-mail encoding '{}' is currently unsupported.", selected_alternative_encoding), "Unsupported"sv, GUI::MessageBox::Type::Information); return; } // FIXME: I'm not sure what the URL should be. Just use the default URL "about:blank". // FIXME: It would be nice if we could pass over the charset. - m_web_view->load_html(decoded_data, "about:blank"); + m_web_view->load_html(decoded_data, "about:blank"sv); } diff --git a/Userland/Applications/Mail/MailboxTreeModel.cpp b/Userland/Applications/Mail/MailboxTreeModel.cpp index 9f783668528..d432b10ce5f 100644 --- a/Userland/Applications/Mail/MailboxTreeModel.cpp +++ b/Userland/Applications/Mail/MailboxTreeModel.cpp @@ -11,9 +11,9 @@ MailboxTreeModel::MailboxTreeModel(AccountHolder const& account_holder) : m_account_holder(account_holder) { - m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png").release_value_but_fixme_should_propagate_errors()); - m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png").release_value_but_fixme_should_propagate_errors()); - m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png").release_value_but_fixme_should_propagate_errors()); + m_mail_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-mail.png"sv).release_value_but_fixme_should_propagate_errors()); + m_folder_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors()); + m_account_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/home-directory.png"sv).release_value_but_fixme_should_propagate_errors()); } GUI::ModelIndex MailboxTreeModel::index(int row, int column, GUI::ModelIndex const& parent) const diff --git a/Userland/Applications/Mail/main.cpp b/Userland/Applications/Mail/main.cpp index 4e8c5e3895e..2396d21b341 100644 --- a/Userland/Applications/Mail/main.cpp +++ b/Userland/Applications/Mail/main.cpp @@ -37,7 +37,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = GUI::Window::construct(); - auto app_icon = GUI::Icon::default_icon("app-mail"); + auto app_icon = GUI::Icon::default_icon("app-mail"sv); window->set_icon(app_icon.bitmap_for_size(16)); auto mail_widget = TRY(window->try_set_main_widget()); diff --git a/Userland/Applications/MailSettings/MailSettingsWidget.cpp b/Userland/Applications/MailSettings/MailSettingsWidget.cpp index deb1da63936..040ad3dc7b4 100644 --- a/Userland/Applications/MailSettings/MailSettingsWidget.cpp +++ b/Userland/Applications/MailSettings/MailSettingsWidget.cpp @@ -17,10 +17,10 @@ void MailSettingsWidget::reset_default_values() { - m_server_inputbox->set_text(""); - m_port_combobox->set_text("993"); + m_server_inputbox->set_text(""sv); + m_port_combobox->set_text("993"sv); m_tls_checkbox->set_checked(false); - m_email_inputbox->set_text(""); + m_email_inputbox->set_text(""sv); } void MailSettingsWidget::apply_settings() @@ -30,10 +30,10 @@ void MailSettingsWidget::apply_settings() m_tls = m_tls_checkbox->is_checked(); m_email = m_email_inputbox->get_text(); - Config::write_string("Mail", "Connection", "Server", m_server); - Config::write_string("Mail", "Connection", "Port", m_port); - Config::write_bool("Mail", "Connection", "TLS", m_tls); - Config::write_string("Mail", "User", "Username", m_email); + Config::write_string("Mail"sv, "Connection"sv, "Server"sv, m_server); + Config::write_string("Mail"sv, "Connection"sv, "Port"sv, m_port); + Config::write_bool("Mail"sv, "Connection"sv, "TLS"sv, m_tls); + Config::write_string("Mail"sv, "User"sv, "Username"sv, m_email); } MailSettingsWidget::MailSettingsWidget() @@ -45,13 +45,13 @@ MailSettingsWidget::MailSettingsWidget() load_from_gml(mail_settings_widget_gml); m_server_inputbox = *find_descendant_of_type_named("server_input"); - m_server_inputbox->set_text(Config::read_string("Mail", "Connection", "Server", "")); + m_server_inputbox->set_text(Config::read_string("Mail"sv, "Connection"sv, "Server"sv, ""sv)); m_server_inputbox->on_change = [&]() { set_modified(true); }; m_port_combobox = *find_descendant_of_type_named("port_input"); - m_port_combobox->set_text(Config::read_string("Mail", "Connection", "Port", "993")); + m_port_combobox->set_text(Config::read_string("Mail"sv, "Connection"sv, "Port"sv, "993"sv)); m_port_combobox->set_only_allow_values_from_model(false); m_port_combobox->set_model(*GUI::ItemListModel::create(m_common_ports)); m_port_combobox->on_change = [&](auto, auto) { @@ -59,13 +59,13 @@ MailSettingsWidget::MailSettingsWidget() }; m_tls_checkbox = *find_descendant_of_type_named("tls_input"); - m_tls_checkbox->set_checked(Config::read_bool("Mail", "Connection", "TLS", false)); + m_tls_checkbox->set_checked(Config::read_bool("Mail"sv, "Connection"sv, "TLS"sv, false)); m_tls_checkbox->on_checked = [&](auto) { set_modified(true); }; m_email_inputbox = *find_descendant_of_type_named("email_input"); - m_email_inputbox->set_text(Config::read_string("Mail", "User", "Username", "")); + m_email_inputbox->set_text(Config::read_string("Mail"sv, "User"sv, "Username"sv, ""sv)); m_email_inputbox->on_change = [&]() { set_modified(true); }; diff --git a/Userland/Applications/MailSettings/main.cpp b/Userland/Applications/MailSettings/main.cpp index 76ad08d7734..75dc3c57a85 100644 --- a/Userland/Applications/MailSettings/main.cpp +++ b/Userland/Applications/MailSettings/main.cpp @@ -31,10 +31,10 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-mail"); + auto app_icon = GUI::Icon::default_icon("app-mail"sv); auto window = TRY(GUI::SettingsWindow::create("Mail Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); - (void)TRY(window->add_tab("Mail", "mail")); + (void)TRY(window->add_tab("Mail"sv, "mail"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->set_active_tab(selected_tab); diff --git a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp index 656c108011b..73fa86d754a 100644 --- a/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp +++ b/Userland/Applications/MouseSettings/DoubleClickArrowWidget.cpp @@ -24,7 +24,7 @@ void DoubleClickArrowWidget::set_double_click_speed(int speed) DoubleClickArrowWidget::DoubleClickArrowWidget() { - m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png").release_value_but_fixme_should_propagate_errors(); + m_arrow_bitmap = Gfx::Bitmap::try_load_from_file("/res/graphics/double-click-down-arrow.png"sv).release_value_but_fixme_should_propagate_errors(); } void DoubleClickArrowWidget::paint_event(GUI::PaintEvent& event) diff --git a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp index cfbd300e2a7..d97c1913c23 100644 --- a/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp +++ b/Userland/Applications/MouseSettings/HighlightPreviewWidget.cpp @@ -30,7 +30,7 @@ ErrorOr HighlightPreviewWidget::reload_cursor() return maybe_bitmap; return Gfx::Bitmap::try_load_from_file(default_path); }; - constexpr auto default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"; + constexpr auto default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"sv; auto cursor_path = String::formatted("/res/cursor-themes/{}/{}", cursor_theme, cursor_theme_config->read_entry("Cursor", "Arrow")); m_cursor_bitmap = TRY(load_bitmap(cursor_path, default_cursor_path)); diff --git a/Userland/Applications/MouseSettings/ThemeWidget.cpp b/Userland/Applications/MouseSettings/ThemeWidget.cpp index c357995e381..2c91c7e2156 100644 --- a/Userland/Applications/MouseSettings/ThemeWidget.cpp +++ b/Userland/Applications/MouseSettings/ThemeWidget.cpp @@ -54,9 +54,9 @@ void MouseCursorModel::invalidate() while (iterator.has_next()) { auto path = iterator.next_full_path(); - if (path.ends_with(".ini")) + if (path.ends_with(".ini"sv)) continue; - if (path.contains("2x")) + if (path.contains("2x"sv)) continue; Cursor cursor; diff --git a/Userland/Applications/MouseSettings/main.cpp b/Userland/Applications/MouseSettings/main.cpp index 82c200c3e48..9564f996e28 100644 --- a/Userland/Applications/MouseSettings/main.cpp +++ b/Userland/Applications/MouseSettings/main.cpp @@ -31,12 +31,12 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_option(selected_tab, "Tab, one of 'cursor-theme', 'cursor-highlight', or 'mouse'", "open-tab", 't', "tab"); args_parser.parse(arguments); - auto app_icon = GUI::Icon::default_icon("app-mouse"); + auto app_icon = GUI::Icon::default_icon("app-mouse"sv); auto window = TRY(GUI::SettingsWindow::create("Mouse Settings", GUI::SettingsWindow::ShowDefaultsButton::Yes)); - (void)TRY(window->add_tab("Mouse", "mouse")); - (void)TRY(window->add_tab("Cursor Theme", "cursor-theme")); - (void)TRY(window->add_tab("Cursor Highlight", "cursor-highlight")); + (void)TRY(window->add_tab("Mouse"sv, "mouse"sv)); + (void)TRY(window->add_tab("Cursor Theme"sv, "cursor-theme"sv)); + (void)TRY(window->add_tab("Cursor Highlight"sv, "cursor-highlight"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->set_active_tab(selected_tab); diff --git a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp index ea65051cd74..2e0e9ad8219 100644 --- a/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp +++ b/Userland/Applications/NetworkSettings/NetworkSettingsWidget.cpp @@ -63,14 +63,14 @@ NetworkSettingsWidget::NetworkSettingsWidget() auto config_file = Core::ConfigFile::open_for_system("Network").release_value_but_fixme_should_propagate_errors(); - auto proc_net_adapters_file = Core::Stream::File::open("/proc/net/adapters", Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); + auto proc_net_adapters_file = Core::Stream::File::open("/proc/net/adapters"sv, Core::Stream::OpenMode::Read).release_value_but_fixme_should_propagate_errors(); auto data = proc_net_adapters_file->read_all().release_value_but_fixme_should_propagate_errors(); JsonParser parser(data); JsonValue proc_net_adapters_json = parser.parse().release_value_but_fixme_should_propagate_errors(); // FIXME: This should be done before creating a window. if (proc_net_adapters_json.as_array().is_empty()) { - GUI::MessageBox::show_error(window(), "No network adapters found!"); + GUI::MessageBox::show_error(window(), "No network adapters found!"sv); ::exit(1); } @@ -78,7 +78,7 @@ NetworkSettingsWidget::NetworkSettingsWidget() size_t index = 0; proc_net_adapters_json.as_array().for_each([&](auto& value) { auto& if_object = value.as_object(); - auto adapter_name = if_object.get("name").to_string(); + auto adapter_name = if_object.get("name"sv).to_string(); if (adapter_name == "loop") return; @@ -160,10 +160,10 @@ void NetworkSettingsWidget::apply_settings() config_file->write_entry(adapter_data.key, "IPv4Gateway", adapter_data.value.default_gateway); } - GUI::Process::spawn_or_show_error(window(), "/bin/NetworkServer"); + GUI::Process::spawn_or_show_error(window(), "/bin/NetworkServer"sv); if (may_need_to_reboot) - GUI::MessageBox::show(window(), "You may need to reboot for changes to take effect.", "Network Settings", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), "You may need to reboot for changes to take effect."sv, "Network Settings"sv, GUI::MessageBox::Type::Warning); } } diff --git a/Userland/Applications/NetworkSettings/main.cpp b/Userland/Applications/NetworkSettings/main.cpp index ca56eb3ea45..b6fb09d7213 100644 --- a/Userland/Applications/NetworkSettings/main.cpp +++ b/Userland/Applications/NetworkSettings/main.cpp @@ -30,15 +30,15 @@ ErrorOr serenity_main(Main::Arguments args) auto app = TRY(GUI::Application::try_create(args)); if (getuid() != 0) { - GUI::MessageBox::show_error(nullptr, "You need to be root to run Network Settings!"); + GUI::MessageBox::show_error(nullptr, "You need to be root to run Network Settings!"sv); return 1; } TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd proc exec")); - auto app_icon = GUI::Icon::default_icon("network"); + auto app_icon = GUI::Icon::default_icon("network"sv); auto window = TRY(GUI::SettingsWindow::create("Network Settings", GUI::SettingsWindow::ShowDefaultsButton::No)); - (void)TRY(window->add_tab("Network", "network")); + (void)TRY(window->add_tab("Network"sv, "network"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->show(); diff --git a/Userland/Applications/PDFViewer/NumericInput.cpp b/Userland/Applications/PDFViewer/NumericInput.cpp index dbd3654c4db..3fb3e79243a 100644 --- a/Userland/Applications/PDFViewer/NumericInput.cpp +++ b/Userland/Applications/PDFViewer/NumericInput.cpp @@ -9,7 +9,7 @@ NumericInput::NumericInput() { - set_text("0"); + set_text("0"sv); on_change = [&] { auto number_opt = text().to_int(); diff --git a/Userland/Applications/PDFViewer/OutlineModel.cpp b/Userland/Applications/PDFViewer/OutlineModel.cpp index 3ae66220f12..125714bc6f4 100644 --- a/Userland/Applications/PDFViewer/OutlineModel.cpp +++ b/Userland/Applications/PDFViewer/OutlineModel.cpp @@ -15,8 +15,8 @@ NonnullRefPtr OutlineModel::create(NonnullRefPtr OutlineModel::OutlineModel(NonnullRefPtr const& outline) : m_outline(outline) { - m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png").release_value_but_fixme_should_propagate_errors()); - m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors()); + m_closed_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book.png"sv).release_value_but_fixme_should_propagate_errors()); + m_open_item_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); } void OutlineModel::set_index_open_state(const GUI::ModelIndex& index, bool is_open) diff --git a/Userland/Applications/PDFViewer/PDFViewer.cpp b/Userland/Applications/PDFViewer/PDFViewer.cpp index 0976f5599fa..1125c2bf480 100644 --- a/Userland/Applications/PDFViewer/PDFViewer.cpp +++ b/Userland/Applications/PDFViewer/PDFViewer.cpp @@ -44,7 +44,7 @@ PDFViewer::PDFViewer() start_timer(30'000); - m_page_view_mode = static_cast(Config::read_i32("PDFViewer", "Display", "PageMode", 0)); + m_page_view_mode = static_cast(Config::read_i32("PDFViewer"sv, "Display"sv, "PageMode"sv, 0)); } PDF::PDFErrorOr PDFViewer::set_document(RefPtr document) @@ -289,7 +289,7 @@ void PDFViewer::rotate(int degrees) void PDFViewer::set_page_view_mode(PageViewMode mode) { m_page_view_mode = mode; - Config::write_i32("PDFViewer", "Display", "PageMode", static_cast(mode)); + Config::write_i32("PDFViewer"sv, "Display"sv, "PageMode"sv, static_cast(mode)); update(); } diff --git a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp index 339d69bc29d..0f388d922d3 100644 --- a/Userland/Applications/PDFViewer/PDFViewerWidget.cpp +++ b/Userland/Applications/PDFViewer/PDFViewerWidget.cpp @@ -65,13 +65,13 @@ void PDFViewerWidget::initialize_menubar(GUI::Window& window) view_menu.add_action(*m_reset_zoom_action); auto& help_menu = window.add_menu("&Help"); - help_menu.add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("PDF Viewer", GUI::Icon::default_icon("app-pdf-viewer"sv), &window)); } void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar) { auto open_outline_action = GUI::Action::create( - "Toggle &Sidebar", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + "Toggle &Sidebar", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/sidebar.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_sidebar_open = !m_sidebar_open; m_sidebar->set_fixed_width(m_sidebar_open ? 200 : 0); }, @@ -82,13 +82,13 @@ void PDFViewerWidget::initialize_toolbar(GUI::Toolbar& toolbar) toolbar.add_action(*open_outline_action); toolbar.add_separator(); - m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_go_to_prev_page_action = GUI::Action::create("Go to &Previous Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-up.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { VERIFY(m_viewer->current_page() > 0); m_page_text_box->set_current_number(m_viewer->current_page()); }); m_go_to_prev_page_action->set_enabled(false); - m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_go_to_next_page_action = GUI::Action::create("Go to &Next Page", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-down.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { VERIFY(m_viewer->current_page() < m_viewer->document()->get_page_count() - 1); m_page_text_box->set_current_number(m_viewer->current_page() + 2); }); diff --git a/Userland/Applications/PDFViewer/main.cpp b/Userland/Applications/PDFViewer/main.cpp index 240194c5c46..73cd91fb5ed 100644 --- a/Userland/Applications/PDFViewer/main.cpp +++ b/Userland/Applications/PDFViewer/main.cpp @@ -24,7 +24,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.parse(arguments); auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"); + auto app_icon = GUI::Icon::default_icon("app-pdf-viewer"sv); Config::pledge_domain("PDFViewer"); diff --git a/Userland/Applications/Piano/KeysWidget.cpp b/Userland/Applications/Piano/KeysWidget.cpp index e43f07fc8c3..e7f48dd06b9 100644 --- a/Userland/Applications/Piano/KeysWidget.cpp +++ b/Userland/Applications/Piano/KeysWidget.cpp @@ -87,30 +87,30 @@ constexpr int black_key_height = 60; constexpr int white_key_labels_count = 12; constexpr Array white_key_labels = { - "A", - "S", - "D", - "F", - "G", - "H", - "J", - "K", - "L", - ";", - "\'", - "\u23CE", // Return key symbol + "A"sv, + "S"sv, + "D"sv, + "F"sv, + "G"sv, + "H"sv, + "J"sv, + "K"sv, + "L"sv, + ";"sv, + "\'"sv, + "\u23CE"sv, // Return key symbol }; constexpr int black_key_labels_count = 8; constexpr Array black_key_labels = { - "W", - "E", - "T", - "Y", - "U", - "O", - "P", - "]", + "W"sv, + "E"sv, + "T"sv, + "Y"sv, + "U"sv, + "O"sv, + "P"sv, + "]"sv, }; constexpr int black_key_offsets[] = { diff --git a/Userland/Applications/Piano/MainWidget.cpp b/Userland/Applications/Piano/MainWidget.cpp index a5ff250dba8..3c19b172443 100644 --- a/Userland/Applications/Piano/MainWidget.cpp +++ b/Userland/Applications/Piano/MainWidget.cpp @@ -55,11 +55,11 @@ MainWidget::MainWidget(TrackManager& track_manager, AudioPlayerLoop& loop) void MainWidget::add_track_actions(GUI::Menu& menu) { - menu.add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + menu.add_action(GUI::Action::create("&Add Track", { Mod_Ctrl, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_player_widget->add_track(); })); - menu.add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + menu.add_action(GUI::Action::create("&Next Track", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { turn_off_pressed_keys(); m_player_widget->next_track(); turn_on_pressed_keys(); diff --git a/Userland/Applications/Piano/Music.h b/Userland/Applications/Piano/Music.h index 75dc9b9ada9..e1f632ab9d8 100644 --- a/Userland/Applications/Piano/Music.h +++ b/Userland/Applications/Piano/Music.h @@ -155,19 +155,19 @@ constexpr int beats_per_bar = 4; constexpr int notes_per_beat = 4; constexpr int roll_length = (sample_rate / (beats_per_minute / 60)) * beats_per_bar; -constexpr char const* note_names[] = { - "C", - "C#", - "D", - "D#", - "E", - "F", - "F#", - "G", - "G#", - "A", - "A#", - "B", +constexpr StringView note_names[] = { + "C"sv, + "C#"sv, + "D"sv, + "D#"sv, + "E"sv, + "F"sv, + "F#"sv, + "G"sv, + "G#"sv, + "A"sv, + "A#"sv, + "B"sv, }; // Equal temperament, A = 440Hz diff --git a/Userland/Applications/Piano/PlayerWidget.cpp b/Userland/Applications/Piano/PlayerWidget.cpp index 3737a601a6c..9084435ce07 100644 --- a/Userland/Applications/Piano/PlayerWidget.cpp +++ b/Userland/Applications/Piano/PlayerWidget.cpp @@ -24,12 +24,12 @@ PlayerWidget::PlayerWidget(TrackManager& manager, AudioPlayerLoop& loop) set_fill_with_background_color(true); m_track_number_choices.append("1"); - m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors(); - m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors(); - m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(); // Go back a note - m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); // Advance a note - m_add_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors(); - m_next_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png").release_value_but_fixme_should_propagate_errors(); + m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors(); + m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors(); + m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(); // Go back a note + m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(); // Advance a note + m_add_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors(); + m_next_track_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-last.png"sv).release_value_but_fixme_should_propagate_errors(); RefPtr label = add("Track"); label->set_max_width(75); diff --git a/Userland/Applications/Piano/RollWidget.cpp b/Userland/Applications/Piano/RollWidget.cpp index 16a20d8cab6..3756acaf4a6 100644 --- a/Userland/Applications/Piano/RollWidget.cpp +++ b/Userland/Applications/Piano/RollWidget.cpp @@ -152,7 +152,7 @@ void RollWidget::paint_event(GUI::PaintEvent& event) } Gfx::IntRect note_name_rect(3, y, 1, note_height); - char const* note_name = note_names[note % notes_per_octave]; + auto note_name = note_names[note % notes_per_octave]; painter.draw_text(note_name_rect, note_name, Gfx::TextAlignment::CenterLeft); note_name_rect.translate_by(Gfx::FontDatabase::default_font().width(note_name) + 2, 0); diff --git a/Userland/Applications/Piano/SamplerWidget.cpp b/Userland/Applications/Piano/SamplerWidget.cpp index 220ed553f5e..372558cd530 100644 --- a/Userland/Applications/Piano/SamplerWidget.cpp +++ b/Userland/Applications/Piano/SamplerWidget.cpp @@ -81,7 +81,7 @@ SamplerWidget::SamplerWidget(TrackManager& track_manager) m_open_button = m_open_button_and_recorded_sample_name_container->add(); m_open_button->set_fixed_size(24, 24); m_open_button->set_focus_policy(GUI::FocusPolicy::TabFocus); - m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors()); + m_open_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); m_open_button->on_click = [this](auto) { Optional open_path = GUI::FilePicker::get_open_filepath(window()); if (!open_path.has_value()) diff --git a/Userland/Applications/Piano/main.cpp b/Userland/Applications/Piano/main.cpp index 6d3ab24b2e2..ab1f33319ee 100644 --- a/Userland/Applications/Piano/main.cpp +++ b/Userland/Applications/Piano/main.cpp @@ -38,7 +38,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto audio_loop = AudioPlayerLoop::construct(track_manager, need_to_write_wav, wav_writer); - auto app_icon = GUI::Icon::default_icon("app-piano"); + auto app_icon = GUI::Icon::default_icon("app-piano"sv); auto window = GUI::Window::construct(); auto main_widget = TRY(window->try_set_main_widget(track_manager, audio_loop)); window->set_title("Piano"); @@ -51,13 +51,13 @@ ErrorOr serenity_main(Main::Arguments arguments) main_widget_updater->start(); auto& file_menu = window->add_menu("&File"); - file_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png")), [&](const GUI::Action&) { + file_menu.add_action(GUI::Action::create("Export", { Mod_Ctrl, Key_E }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"sv)), [&](const GUI::Action&) { save_path = GUI::FilePicker::get_save_filepath(window, "Untitled", "wav"); if (!save_path.has_value()) return; wav_writer.set_file(save_path.value()); if (wav_writer.has_error()) { - GUI::MessageBox::show(window, String::formatted("Failed to export WAV file: {}", wav_writer.error_string()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Failed to export WAV file: {}", wav_writer.error_string()), "Error"sv, GUI::MessageBox::Type::Error); wav_writer.clear_error(); return; } diff --git a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp index a29d8935c06..56f9c44dc67 100644 --- a/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewImageDialog.cpp @@ -34,7 +34,7 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window) m_name_textbox->on_change = [this] { m_image_name = m_name_textbox->text(); }; - auto default_name = Config::read_string("PixelPaint", "NewImage", "Name"); + auto default_name = Config::read_string("PixelPaint"sv, "NewImage"sv, "Name"sv); m_name_textbox->set_text(default_name); auto& width_label = main_widget.add("Width:"); @@ -72,8 +72,8 @@ CreateNewImageDialog::CreateNewImageDialog(GUI::Window* parent_window) width_spinbox.set_range(1, 16384); height_spinbox.set_range(1, 16384); - auto default_width = Config::read_i32("PixelPaint", "NewImage", "Width", 510); - auto default_height = Config::read_i32("PixelPaint", "NewImage", "Height", 356); + auto default_width = Config::read_i32("PixelPaint"sv, "NewImage"sv, "Width"sv, 510); + auto default_height = Config::read_i32("PixelPaint"sv, "NewImage"sv, "Height"sv, 356); width_spinbox.set_value(default_width); height_spinbox.set_value(default_height); } diff --git a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp index a681c210158..89f41220bb2 100644 --- a/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp +++ b/Userland/Applications/PixelPaint/CreateNewLayerDialog.cpp @@ -30,7 +30,7 @@ CreateNewLayerDialog::CreateNewLayerDialog(Gfx::IntSize const& suggested_size, G name_label.set_text_alignment(Gfx::TextAlignment::CenterLeft); m_name_textbox = main_widget.add(); - m_name_textbox->set_text("Layer"); + m_name_textbox->set_text("Layer"sv); m_name_textbox->select_all(); m_name_textbox->on_change = [this] { m_layer_name = m_name_textbox->text(); diff --git a/Userland/Applications/PixelPaint/FilterParams.h b/Userland/Applications/PixelPaint/FilterParams.h index dcbda9220eb..57d602ff889 100644 --- a/Userland/Applications/PixelPaint/FilterParams.h +++ b/Userland/Applications/PixelPaint/FilterParams.h @@ -44,7 +44,7 @@ private: // FIXME: Help! Make this GUI less ugly. StringBuilder builder; builder.appendff("{}x{}", N, N); - builder.append(" Convolution"); + builder.append(" Convolution"sv); set_title(builder.string_view()); resize(200, 250); @@ -73,7 +73,7 @@ private: if (endptr != nullptr) element = value; else - textbox.set_text(""); + textbox.set_text(""sv); }; } else { horizontal_container.template add(); diff --git a/Userland/Applications/PixelPaint/FilterTreeModel.cpp b/Userland/Applications/PixelPaint/FilterTreeModel.cpp index cdfc24bf1c1..07133f1e83c 100644 --- a/Userland/Applications/PixelPaint/FilterTreeModel.cpp +++ b/Userland/Applications/PixelPaint/FilterTreeModel.cpp @@ -26,7 +26,7 @@ namespace PixelPaint { ErrorOr> create_filter_tree_model(ImageEditor* editor) { auto directory_icon = GUI::FileIconProvider::directory_icon(); - auto filter_icon = GUI::Icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"))); + auto filter_icon = GUI::Icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"sv))); auto filter_tree_model = GUI::TreeViewModel::create(); diff --git a/Userland/Applications/PixelPaint/IconBag.cpp b/Userland/Applications/PixelPaint/IconBag.cpp index ec0d45f1cd2..0cd63b08d48 100644 --- a/Userland/Applications/PixelPaint/IconBag.cpp +++ b/Userland/Applications/PixelPaint/IconBag.cpp @@ -12,35 +12,35 @@ ErrorOr IconBag::try_create() { IconBag icon_bag; - icon_bag.filetype_pixelpaint = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png")); - icon_bag.new_clipboard = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png")); - icon_bag.file_export = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png")); - icon_bag.close_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png")); - icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png")); - icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png")); - icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png")); - icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png")); - icon_bag.load_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/load-color-palette.png")); - icon_bag.save_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/save-color-palette.png")); - icon_bag.add_guide = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/add-guide.png")); - icon_bag.clear_guides = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/clear-guides.png")); - icon_bag.edit_flip_vertical = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png")); - icon_bag.edit_flip_horizontal = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png")); - icon_bag.resize_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png")); - icon_bag.crop = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/crop.png")); - icon_bag.new_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png")); - icon_bag.previous_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png")); - icon_bag.next_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png")); - icon_bag.top_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png")); - icon_bag.bottom_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png")); - icon_bag.active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png")); - icon_bag.active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png")); - icon_bag.delete_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png")); - icon_bag.merge_visible = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-visible.png")); - icon_bag.merge_active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-up.png")); - icon_bag.merge_active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-down.png")); - icon_bag.filter = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png")); - icon_bag.levels = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/levels.png")); + icon_bag.filetype_pixelpaint = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-pixelpaint.png"sv)); + icon_bag.new_clipboard = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/new-clipboard.png"sv)); + icon_bag.file_export = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/file-export.png"sv)); + icon_bag.close_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/close-tab.png"sv)); + icon_bag.edit_copy = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv)); + icon_bag.clear_selection = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/clear-selection.png"sv)); + icon_bag.swap_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/swap-colors.png"sv)); + icon_bag.default_colors = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/default-colors.png"sv)); + icon_bag.load_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/load-color-palette.png"sv)); + icon_bag.save_color_palette = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/save-color-palette.png"sv)); + icon_bag.add_guide = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/add-guide.png"sv)); + icon_bag.clear_guides = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/clear-guides.png"sv)); + icon_bag.edit_flip_vertical = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-vertical.png"sv)); + icon_bag.edit_flip_horizontal = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-flip-horizontal.png"sv)); + icon_bag.resize_image = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/selection-move.png"sv)); + icon_bag.crop = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/crop.png"sv)); + icon_bag.new_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-layer.png"sv)); + icon_bag.previous_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/previous-layer.png"sv)); + icon_bag.next_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/next-layer.png"sv)); + icon_bag.top_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/top-layer.png"sv)); + icon_bag.bottom_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/bottom-layer.png"sv)); + icon_bag.active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-up.png"sv)); + icon_bag.active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/active-layer-down.png"sv)); + icon_bag.delete_layer = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv)); + icon_bag.merge_visible = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-visible.png"sv)); + icon_bag.merge_active_layer_up = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-up.png"sv)); + icon_bag.merge_active_layer_down = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/merge-active-layer-down.png"sv)); + icon_bag.filter = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/filter.png"sv)); + icon_bag.levels = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/levels.png"sv)); return icon_bag; } diff --git a/Userland/Applications/PixelPaint/Image.cpp b/Userland/Applications/PixelPaint/Image.cpp index 07cb6200b8b..ac616c3968c 100644 --- a/Userland/Applications/PixelPaint/Image.cpp +++ b/Userland/Applications/PixelPaint/Image.cpp @@ -85,37 +85,37 @@ ErrorOr> Image::try_create_from_bitmap(NonnullRefPtr> Image::try_create_from_pixel_paint_json(JsonObject const& json) { - auto image = TRY(try_create_with_size({ json.get("width").to_i32(), json.get("height").to_i32() })); + auto image = TRY(try_create_with_size({ json.get("width"sv).to_i32(), json.get("height"sv).to_i32() })); - auto layers_value = json.get("layers"); + auto layers_value = json.get("layers"sv); for (auto& layer_value : layers_value.as_array().values()) { auto& layer_object = layer_value.as_object(); - auto name = layer_object.get("name").as_string(); + auto name = layer_object.get("name"sv).as_string(); - auto bitmap_base64_encoded = layer_object.get("bitmap").as_string(); + auto bitmap_base64_encoded = layer_object.get("bitmap"sv).as_string(); auto bitmap_data = TRY(decode_base64(bitmap_base64_encoded)); auto bitmap = TRY(try_decode_bitmap(bitmap_data)); auto layer = TRY(Layer::try_create_with_bitmap(*image, move(bitmap), name)); - if (auto mask_object = layer_object.get("mask"); !mask_object.is_null()) { + if (auto mask_object = layer_object.get("mask"sv); !mask_object.is_null()) { auto mask_base64_encoded = mask_object.as_string(); auto mask_data = TRY(decode_base64(mask_base64_encoded)); auto mask = TRY(try_decode_bitmap(mask_data)); TRY(layer->try_set_bitmaps(layer->content_bitmap(), mask)); } - auto width = layer_object.get("width").to_i32(); - auto height = layer_object.get("height").to_i32(); + auto width = layer_object.get("width"sv).to_i32(); + auto height = layer_object.get("height"sv).to_i32(); if (width != layer->size().width() || height != layer->size().height()) return Error::from_string_literal("Decoded layer bitmap has wrong size"); image->add_layer(*layer); - layer->set_location({ layer_object.get("locationx").to_i32(), layer_object.get("locationy").to_i32() }); - layer->set_opacity_percent(layer_object.get("opacity_percent").to_i32()); - layer->set_visible(layer_object.get("visible").as_bool()); - layer->set_selected(layer_object.get("selected").as_bool()); + layer->set_location({ layer_object.get("locationx"sv).to_i32(), layer_object.get("locationy"sv).to_i32() }); + layer->set_opacity_percent(layer_object.get("opacity_percent"sv).to_i32()); + layer->set_visible(layer_object.get("visible"sv).as_bool()); + layer->set_selected(layer_object.get("selected"sv).as_bool()); } return image; @@ -123,24 +123,24 @@ ErrorOr> Image::try_create_from_pixel_paint_json(JsonObject void Image::serialize_as_json(JsonObjectSerializer& json) const { - MUST(json.add("width", m_size.width())); - MUST(json.add("height", m_size.height())); + MUST(json.add("width"sv, m_size.width())); + MUST(json.add("height"sv, m_size.height())); { - auto json_layers = MUST(json.add_array("layers")); + auto json_layers = MUST(json.add_array("layers"sv)); for (auto const& layer : m_layers) { Gfx::BMPWriter bmp_writer; auto json_layer = MUST(json_layers.add_object()); - MUST(json_layer.add("width", layer.size().width())); - MUST(json_layer.add("height", layer.size().height())); - MUST(json_layer.add("name", layer.name())); - MUST(json_layer.add("locationx", layer.location().x())); - MUST(json_layer.add("locationy", layer.location().y())); - MUST(json_layer.add("opacity_percent", layer.opacity_percent())); - MUST(json_layer.add("visible", layer.is_visible())); - MUST(json_layer.add("selected", layer.is_selected())); - MUST(json_layer.add("bitmap", encode_base64(bmp_writer.dump(layer.content_bitmap())))); + MUST(json_layer.add("width"sv, layer.size().width())); + MUST(json_layer.add("height"sv, layer.size().height())); + MUST(json_layer.add("name"sv, layer.name())); + MUST(json_layer.add("locationx"sv, layer.location().x())); + MUST(json_layer.add("locationy"sv, layer.location().y())); + MUST(json_layer.add("opacity_percent"sv, layer.opacity_percent())); + MUST(json_layer.add("visible"sv, layer.is_visible())); + MUST(json_layer.add("selected"sv, layer.is_selected())); + MUST(json_layer.add("bitmap"sv, encode_base64(bmp_writer.dump(layer.content_bitmap())))); if (layer.is_masked()) - MUST(json_layer.add("mask", encode_base64(bmp_writer.dump(*layer.mask_bitmap())))); + MUST(json_layer.add("mask"sv, encode_base64(bmp_writer.dump(*layer.mask_bitmap())))); MUST(json_layer.finish()); } diff --git a/Userland/Applications/PixelPaint/ImageEditor.cpp b/Userland/Applications/PixelPaint/ImageEditor.cpp index 8a3ffb26d96..2a3e54b7c06 100644 --- a/Userland/Applications/PixelPaint/ImageEditor.cpp +++ b/Userland/Applications/PixelPaint/ImageEditor.cpp @@ -36,11 +36,11 @@ ImageEditor::ImageEditor(NonnullRefPtr image) set_original_rect(m_image->rect()); set_scale_bounds(0.1f, 100.0f); - m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint", "PixelGrid", "Threshold", 15); - m_show_pixel_grid = Config::read_bool("PixelPaint", "PixelGrid", "Show", true); + m_pixel_grid_threshold = (float)Config::read_i32("PixelPaint"sv, "PixelGrid"sv, "Threshold"sv, 15); + m_show_pixel_grid = Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true); - m_show_rulers = Config::read_bool("PixelPaint", "Rulers", "Show", true); - m_show_guides = Config::read_bool("PixelPaint", "Guides", "Show", true); + m_show_rulers = Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true); + m_show_guides = Config::read_bool("PixelPaint"sv, "Guides"sv, "Show"sv, true); } ImageEditor::~ImageEditor() @@ -618,14 +618,14 @@ Result ImageEditor::save_project_to_file(Core::File& file) const StringBuilder builder; auto json = MUST(JsonObjectSerializer<>::try_create(builder)); m_image->serialize_as_json(json); - auto json_guides = MUST(json.add_array("guides")); + auto json_guides = MUST(json.add_array("guides"sv)); for (auto const& guide : m_guides) { auto json_guide = MUST(json_guides.add_object()); MUST(json_guide.add("offset"sv, (double)guide.offset())); if (guide.orientation() == Guide::Orientation::Vertical) - MUST(json_guide.add("orientation", "vertical")); + MUST(json_guide.add("orientation"sv, "vertical")); else if (guide.orientation() == Guide::Orientation::Horizontal) - MUST(json_guide.add("orientation", "horizontal")); + MUST(json_guide.add("orientation"sv, "horizontal")); MUST(json_guide.finish()); } MUST(json_guides.finish()); diff --git a/Userland/Applications/PixelPaint/LayerPropertiesWidget.cpp b/Userland/Applications/PixelPaint/LayerPropertiesWidget.cpp index af03fd75308..1ad8a5329b3 100644 --- a/Userland/Applications/PixelPaint/LayerPropertiesWidget.cpp +++ b/Userland/Applications/PixelPaint/LayerPropertiesWidget.cpp @@ -23,7 +23,7 @@ LayerPropertiesWidget::LayerPropertiesWidget() { set_layout(); - auto& group_box = add("Layer properties"); + auto& group_box = add("Layer properties"sv); auto& layout = group_box.set_layout(); layout.set_margins({ 8 }); diff --git a/Userland/Applications/PixelPaint/MainWidget.cpp b/Userland/Applications/PixelPaint/MainWidget.cpp index bea5d9e631a..b1fe758fe22 100644 --- a/Userland/Applications/PixelPaint/MainWidget.cpp +++ b/Userland/Applications/PixelPaint/MainWidget.cpp @@ -174,7 +174,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto response = FileSystemAccessClient::Client::the().try_save_file(&window, "untitled", "bmp"); if (response.is_error()) return; - auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); auto result = editor->image().export_bmp_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes); if (result.is_error()) GUI::MessageBox::show_error(&window, String::formatted("Export to BMP failed: {}", result.error())); @@ -189,7 +189,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto response = FileSystemAccessClient::Client::the().try_save_file(&window, "untitled", "png"); if (response.is_error()) return; - auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?", "Preserve transparency?", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto preserve_alpha_channel = GUI::MessageBox::show(&window, "Do you wish to preserve transparency?"sv, "Preserve transparency?"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); auto result = editor->image().export_png_to_file(response.value(), preserve_alpha_channel == GUI::MessageBox::ExecResult::Yes); if (result.is_error()) GUI::MessageBox::show_error(&window, String::formatted("Export to PNG failed: {}", result.error())); @@ -407,12 +407,12 @@ void MainWidget::initialize_menubar(GUI::Window& window) // Save this so other methods can use it m_show_guides_action = GUI::Action::create_checkable( "Show &Guides", [&](auto& action) { - Config::write_bool("PixelPaint", "Guides", "Show", action.is_checked()); + Config::write_bool("PixelPaint"sv, "Guides"sv, "Show"sv, action.is_checked()); auto* editor = current_image_editor(); VERIFY(editor); editor->set_guide_visibility(action.is_checked()); }); - m_show_guides_action->set_checked(Config::read_bool("PixelPaint", "Guides", "Show", true)); + m_show_guides_action->set_checked(Config::read_bool("PixelPaint"sv, "Guides"sv, "Show"sv, true)); m_view_menu->add_action(*m_zoom_in_action); m_view_menu->add_action(*m_zoom_out_action); @@ -437,32 +437,32 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto show_pixel_grid_action = GUI::Action::create_checkable( "Show &Pixel Grid", [&](auto& action) { - Config::write_bool("PixelPaint", "PixelGrid", "Show", action.is_checked()); + Config::write_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, action.is_checked()); auto* editor = current_image_editor(); VERIFY(editor); editor->set_pixel_grid_visibility(action.is_checked()); }); - show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint", "PixelGrid", "Show", true)); + show_pixel_grid_action->set_checked(Config::read_bool("PixelPaint"sv, "PixelGrid"sv, "Show"sv, true)); m_view_menu->add_action(*show_pixel_grid_action); m_show_rulers_action = GUI::Action::create_checkable( "Show R&ulers", { Mod_Ctrl, Key_R }, [&](auto& action) { - Config::write_bool("PixelPaint", "Rulers", "Show", action.is_checked()); + Config::write_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, action.is_checked()); auto* editor = current_image_editor(); VERIFY(editor); editor->set_ruler_visibility(action.is_checked()); }); - m_show_rulers_action->set_checked(Config::read_bool("PixelPaint", "Rulers", "Show", true)); + m_show_rulers_action->set_checked(Config::read_bool("PixelPaint"sv, "Rulers"sv, "Show"sv, true)); m_view_menu->add_action(*m_show_rulers_action); m_show_active_layer_boundary_action = GUI::Action::create_checkable( "Show Active Layer &Boundary", [&](auto& action) { - Config::write_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", action.is_checked()); + Config::write_bool("PixelPaint"sv, "ImageEditor"sv, "ShowActiveLayerBoundary"sv, action.is_checked()); auto* editor = current_image_editor(); VERIFY(editor); editor->set_show_active_layer_boundary(action.is_checked()); }); - m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint", "ImageEditor", "ShowActiveLayerBoundary", true)); + m_show_active_layer_boundary_action->set_checked(Config::read_bool("PixelPaint"sv, "ImageEditor"sv, "ShowActiveLayerBoundary"sv, true)); m_view_menu->add_action(*m_show_active_layer_boundary_action); m_tool_menu = window.add_menu("&Tool"); @@ -700,7 +700,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) })); auto& help_menu = window.add_menu("&Help"); - help_menu.add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("Pixel Paint", GUI::Icon::default_icon("app-pixel-paint"sv), &window)); m_levels_dialog_action = GUI::Action::create( "Change &Levels...", { Mod_Ctrl, Key_L }, g_icon_bag.levels, [&](auto&) { @@ -825,7 +825,7 @@ void MainWidget::create_image_from_clipboard() { auto bitmap = GUI::Clipboard::the().fetch_data_and_type().as_bitmap(); if (!bitmap) { - GUI::MessageBox::show(window(), "There is no image in a clipboard to paste.", "PixelPaint", GUI::MessageBox::Type::Warning); + GUI::MessageBox::show(window(), "There is no image in a clipboard to paste."sv, "PixelPaint"sv, GUI::MessageBox::Type::Warning); return; } diff --git a/Userland/Applications/PixelPaint/PaletteWidget.cpp b/Userland/Applications/PixelPaint/PaletteWidget.cpp index bb5a7702df1..955430a7b71 100644 --- a/Userland/Applications/PixelPaint/PaletteWidget.cpp +++ b/Userland/Applications/PixelPaint/PaletteWidget.cpp @@ -264,7 +264,7 @@ Result PaletteWidget::save_palette_file(Vector palette, Cor { for (auto& color : palette) { file.write(color.to_string_without_alpha()); - file.write("\n"); + file.write("\n"sv); } return {}; } diff --git a/Userland/Applications/PixelPaint/ProjectLoader.cpp b/Userland/Applications/PixelPaint/ProjectLoader.cpp index 8cb03deebd1..3356abbd13a 100644 --- a/Userland/Applications/PixelPaint/ProjectLoader.cpp +++ b/Userland/Applications/PixelPaint/ProjectLoader.cpp @@ -35,8 +35,8 @@ ErrorOr ProjectLoader::try_load_from_file(Core::File& file) auto& json = json_or_error.value().as_object(); auto image = TRY(Image::try_create_from_pixel_paint_json(json)); - if (json.has("guides")) - m_json_metadata = json.get("guides").as_array(); + if (json.has("guides"sv)) + m_json_metadata = json.get("guides"sv).as_array(); m_image = image; return {}; diff --git a/Userland/Applications/PixelPaint/ToolPropertiesWidget.cpp b/Userland/Applications/PixelPaint/ToolPropertiesWidget.cpp index 1353bf91b01..e69a3f4bb89 100644 --- a/Userland/Applications/PixelPaint/ToolPropertiesWidget.cpp +++ b/Userland/Applications/PixelPaint/ToolPropertiesWidget.cpp @@ -18,7 +18,7 @@ ToolPropertiesWidget::ToolPropertiesWidget() { set_layout(); - m_group_box = add("Tool properties"); + m_group_box = add("Tool properties"sv); auto& layout = m_group_box->set_layout(); layout.set_margins({ 8 }); m_tool_widget_stack = m_group_box->add(); diff --git a/Userland/Applications/PixelPaint/ToolboxWidget.cpp b/Userland/Applications/PixelPaint/ToolboxWidget.cpp index 7cb2e6e0d52..d1cc9a599df 100644 --- a/Userland/Applications/PixelPaint/ToolboxWidget.cpp +++ b/Userland/Applications/PixelPaint/ToolboxWidget.cpp @@ -68,20 +68,20 @@ void ToolboxWidget::setup_tools() m_tools.append(move(tool)); }; - add_tool("Move", "move", { 0, Key_M }, make()); - add_tool("Pen", "pen", { 0, Key_N }, make()); - add_tool("Brush", "brush", { 0, Key_P }, make()); - add_tool("Bucket Fill", "bucket", { Mod_Shift, Key_B }, make()); - add_tool("Spray", "spray", { Mod_Shift, Key_S }, make()); - add_tool("Color Picker", "picker", { 0, Key_O }, make()); - add_tool("Erase", "eraser", { Mod_Shift, Key_E }, make()); - add_tool("Line", "line", { Mod_Ctrl | Mod_Shift, Key_L }, make()); - add_tool("Rectangle", "rectangle", { Mod_Ctrl | Mod_Shift, Key_R }, make()); - add_tool("Ellipse", "circle", { Mod_Ctrl | Mod_Shift, Key_E }, make()); - add_tool("Zoom", "zoom", { 0, Key_Z }, make()); - add_tool("Rectangle Select", "rectangle-select", { 0, Key_R }, make()); - add_tool("Guides", "guides", { 0, Key_G }, make()); - add_tool("Clone Tool", "clone", { 0, Key_C }, make()); + add_tool("Move", "move"sv, { 0, Key_M }, make()); + add_tool("Pen", "pen"sv, { 0, Key_N }, make()); + add_tool("Brush", "brush"sv, { 0, Key_P }, make()); + add_tool("Bucket Fill", "bucket"sv, { Mod_Shift, Key_B }, make()); + add_tool("Spray", "spray"sv, { Mod_Shift, Key_S }, make()); + add_tool("Color Picker", "picker"sv, { 0, Key_O }, make()); + add_tool("Erase", "eraser"sv, { Mod_Shift, Key_E }, make()); + add_tool("Line", "line"sv, { Mod_Ctrl | Mod_Shift, Key_L }, make()); + add_tool("Rectangle", "rectangle"sv, { Mod_Ctrl | Mod_Shift, Key_R }, make()); + add_tool("Ellipse", "circle"sv, { Mod_Ctrl | Mod_Shift, Key_E }, make()); + add_tool("Zoom", "zoom"sv, { 0, Key_Z }, make()); + add_tool("Rectangle Select", "rectangle-select"sv, { 0, Key_R }, make()); + add_tool("Guides", "guides"sv, { 0, Key_G }, make()); + add_tool("Clone Tool", "clone"sv, { 0, Key_C }, make()); } } diff --git a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp index a22c814706f..3483c4f60ce 100644 --- a/Userland/Applications/PixelPaint/Tools/BucketTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/BucketTool.cpp @@ -22,7 +22,7 @@ namespace PixelPaint { BucketTool::BucketTool() { - m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png").release_value_but_fixme_should_propagate_errors(); + m_cursor = Gfx::Bitmap::try_load_from_file("/res/icons/pixelpaint/bucket.png"sv).release_value_but_fixme_should_propagate_errors(); } static float color_distance_squared(Gfx::Color const& lhs, Gfx::Color const& rhs) diff --git a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp index daa86434c46..5ec08bd599f 100644 --- a/Userland/Applications/PixelPaint/Tools/GuideTool.cpp +++ b/Userland/Applications/PixelPaint/Tools/GuideTool.cpp @@ -135,7 +135,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event) if (!m_context_menu) { m_context_menu = GUI::Menu::construct(); m_context_menu->add_action(GUI::Action::create( - "Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + "Set &Offset", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/gear.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (!m_context_menu_guide) return; auto dialog = EditGuideDialog::construct( @@ -153,7 +153,7 @@ void GuideTool::on_context_menu(Layer*, GUI::ContextMenuEvent& event) }, editor())); m_context_menu->add_action(GUI::Action::create( - "&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + "&Delete Guide", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (!m_context_menu_guide) return; editor()->remove_guide(*m_context_menu_guide); diff --git a/Userland/Applications/PixelPaint/main.cpp b/Userland/Applications/PixelPaint/main.cpp index 47cf207c3fa..fffe3a79ab8 100644 --- a/Userland/Applications/PixelPaint/main.cpp +++ b/Userland/Applications/PixelPaint/main.cpp @@ -38,7 +38,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-pixel-paint"); + auto app_icon = GUI::Icon::default_icon("app-pixel-paint"sv); PixelPaint::g_icon_bag = TRY(PixelPaint::IconBag::try_create()); diff --git a/Userland/Applications/Run/RunWindow.cpp b/Userland/Applications/Run/RunWindow.cpp index 3c551b0f2f5..20c97e80c77 100644 --- a/Userland/Applications/Run/RunWindow.cpp +++ b/Userland/Applications/Run/RunWindow.cpp @@ -31,7 +31,7 @@ RunWindow::RunWindow() { load_history(); - auto app_icon = GUI::Icon::default_icon("app-run"); + auto app_icon = GUI::Icon::default_icon("app-run"sv); set_title("Run"); set_icon(app_icon.bitmap_for_size(16)); @@ -101,7 +101,7 @@ void RunWindow::do_run() return; } - GUI::MessageBox::show_error(this, "Failed to run. Please check your command, path, or address, and try again."); + GUI::MessageBox::show_error(this, "Failed to run. Please check your command, path, or address, and try again."sv); show(); } diff --git a/Userland/Applications/Settings/main.cpp b/Userland/Applications/Settings/main.cpp index 74368deef94..9f3acbac66a 100644 --- a/Userland/Applications/Settings/main.cpp +++ b/Userland/Applications/Settings/main.cpp @@ -76,7 +76,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio thread recvfd sendfd rpath cpath wpath proc exec")); - auto app_icon = GUI::Icon::default_icon("app-settings"); + auto app_icon = GUI::Icon::default_icon("app-settings"sv); auto window = TRY(GUI::Window::try_create()); window->set_title("Settings"); diff --git a/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp b/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp index 888c555257d..ceb468e6cd3 100644 --- a/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp +++ b/Userland/Applications/SoundPlayer/AlbumCoverVisualizationWidget.cpp @@ -30,7 +30,7 @@ void AlbumCoverVisualizationWidget::paint_event(GUI::PaintEvent& event) painter.draw_scaled_bitmap(fitted_rect, *m_album_cover, m_album_cover->rect(), 1.0f); } else { if (!m_serenity_bg) - m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png").release_value_but_fixme_should_propagate_errors(); + m_serenity_bg = Gfx::Bitmap::try_load_from_file("/res/wallpapers/sunset-retro.png"sv).release_value_but_fixme_should_propagate_errors(); painter.draw_scaled_bitmap(frame_inner_rect(), *m_serenity_bg, m_serenity_bg->rect(), 1.0f); } } diff --git a/Userland/Applications/SoundPlayer/M3UParser.cpp b/Userland/Applications/SoundPlayer/M3UParser.cpp index 8454d03781f..a09a40caa5c 100644 --- a/Userland/Applications/SoundPlayer/M3UParser.cpp +++ b/Userland/Applications/SoundPlayer/M3UParser.cpp @@ -20,7 +20,7 @@ NonnullOwnPtr M3UParser::from_file(const String path) auto file_result = Core::File::open(path, Core::OpenMode::ReadOnly); VERIFY(!file_result.is_error()); auto contents = file_result.value()->read_all(); - auto use_utf8 = path.ends_with(".m3u8", CaseSensitivity::CaseInsensitive); + auto use_utf8 = path.ends_with(".m3u8"sv, CaseSensitivity::CaseInsensitive); return from_memory(String { contents, NoChomp }, use_utf8); } @@ -66,7 +66,7 @@ NonnullOwnPtr> M3UParser::parse(bool include_extended_info) return {}; }; - if (auto ext_inf = tag("#EXTINF:"); ext_inf.has_value()) { + if (auto ext_inf = tag("#EXTINF:"sv); ext_inf.has_value()) { auto separator = ext_inf.value().find(','); VERIFY(separator.has_value()); auto seconds = ext_inf.value().substring_view(0, separator.value()); @@ -78,15 +78,15 @@ NonnullOwnPtr> M3UParser::parse(bool include_extended_info) // TODO: support the alternative, non-standard #EXTINF value of a key=value dictionary continue; } - if (auto playlist = tag("#PLAYLIST:"); playlist.has_value()) + if (auto playlist = tag("#PLAYLIST:"sv); playlist.has_value()) m_parsed_playlist_title = move(playlist.value()); - else if (auto ext_grp = tag("#EXTGRP:"); ext_grp.has_value()) + else if (auto ext_grp = tag("#EXTGRP:"sv); ext_grp.has_value()) metadata_for_next_file.group_name = move(ext_grp.value()); - else if (auto ext_alb = tag("#EXTALB:"); ext_alb.has_value()) + else if (auto ext_alb = tag("#EXTALB:"sv); ext_alb.has_value()) metadata_for_next_file.album_title = move(ext_alb.value()); - else if (auto ext_art = tag("#EXTART:"); ext_art.has_value()) + else if (auto ext_art = tag("#EXTART:"sv); ext_art.has_value()) metadata_for_next_file.album_artist = move(ext_art.value()); - else if (auto ext_genre = tag("#EXTGENRE:"); ext_genre.has_value()) + else if (auto ext_genre = tag("#EXTGENRE:"sv); ext_genre.has_value()) metadata_for_next_file.album_genre = move(ext_genre.value()); // TODO: Support M3A files (M3U files with embedded mp3 files) } diff --git a/Userland/Applications/SoundPlayer/Player.cpp b/Userland/Applications/SoundPlayer/Player.cpp index 30dee3becb3..384626ac5ba 100644 --- a/Userland/Applications/SoundPlayer/Player.cpp +++ b/Userland/Applications/SoundPlayer/Player.cpp @@ -44,7 +44,7 @@ void Player::play_file_path(String const& path) return; if (!Core::File::exists(path)) { - audio_load_error(path, "File does not exist"); + audio_load_error(path, "File does not exist"sv); return; } @@ -71,8 +71,8 @@ void Player::play_file_path(String const& path) bool Player::is_playlist(String const& path) { - return (path.ends_with(".m3u", AK::CaseSensitivity::CaseInsensitive) - || path.ends_with(".m3u8", AK::CaseSensitivity::CaseInsensitive)); + return (path.ends_with(".m3u"sv, AK::CaseSensitivity::CaseInsensitive) + || path.ends_with(".m3u8"sv, AK::CaseSensitivity::CaseInsensitive)); } void Player::set_play_state(PlayState state) diff --git a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp index bef376a83b4..1bd46f03667 100644 --- a/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp +++ b/Userland/Applications/SoundPlayer/SoundPlayerWidgetAdvancedView.cpp @@ -43,11 +43,11 @@ SoundPlayerWidgetAdvancedView::SoundPlayerWidgetAdvancedView(GUI::Window& window m_player_view->set_layout(); - m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors(); - m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors(); - m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png").release_value_but_fixme_should_propagate_errors(); - m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(); - m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); + m_play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors(); + m_pause_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors(); + m_stop_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop.png"sv).release_value_but_fixme_should_propagate_errors(); + m_back_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(); + m_next_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(); m_visualization = m_player_view->add(); @@ -224,7 +224,7 @@ void SoundPlayerWidgetAdvancedView::volume_changed(double volume) void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded) { if (!loaded) { - GUI::MessageBox::show(&m_window, String::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(&m_window, String::formatted("Could not load playlist at \"{}\".", path), "Error opening playlist"sv, GUI::MessageBox::Type::Error); return; } set_playlist_visible(true); @@ -233,6 +233,6 @@ void SoundPlayerWidgetAdvancedView::playlist_loaded(StringView path, bool loaded void SoundPlayerWidgetAdvancedView::audio_load_error(StringView path, StringView error_string) { - GUI::MessageBox::show(&m_window, String::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error" : error_string), - "Filetype error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(&m_window, String::formatted("Failed to load audio file: {} ({})", path, error_string.is_null() ? "Unknown error"sv : error_string), + "Filetype error"sv, GUI::MessageBox::Type::Error); } diff --git a/Userland/Applications/SoundPlayer/main.cpp b/Userland/Applications/SoundPlayer/main.cpp index 8ff1a76621e..42918d8584f 100644 --- a/Userland/Applications/SoundPlayer/main.cpp +++ b/Userland/Applications/SoundPlayer/main.cpp @@ -32,7 +32,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath thread")); - auto app_icon = GUI::Icon::default_icon("app-sound-player"); + auto app_icon = GUI::Icon::default_icon("app-sound-player"sv); auto window = TRY(GUI::Window::try_create()); window->set_title("Sound Player"); diff --git a/Userland/Applications/SpaceAnalyzer/main.cpp b/Userland/Applications/SpaceAnalyzer/main.cpp index 62ff16025b8..b7909ff5be8 100644 --- a/Userland/Applications/SpaceAnalyzer/main.cpp +++ b/Userland/Applications/SpaceAnalyzer/main.cpp @@ -30,7 +30,7 @@ #include #include -static constexpr StringView APP_NAME = "Space Analyzer"; +static constexpr auto APP_NAME = "Space Analyzer"sv; static constexpr size_t FILES_ENCOUNTERED_UPDATE_STEP_SIZE = 25; struct TreeNode : public SpaceAnalyzer::TreeMapNode { @@ -88,11 +88,11 @@ static void fill_mounts(Vector& output) auto content = file->read_all(); auto json = JsonValue::from_string(content).release_value_but_fixme_should_propagate_errors(); - json.as_array().for_each([&output](auto& value) { + json.as_array().for_each([&output](JsonValue const& value) { auto& filesystem_object = value.as_object(); MountInfo mount_info; - mount_info.mount_point = filesystem_object.get("mount_point").to_string(); - mount_info.source = filesystem_object.get("source").as_string_or("none"); + mount_info.mount_point = filesystem_object.get("mount_point"sv).to_string(); + mount_info.source = filesystem_object.get("source"sv).as_string_or("none"sv); output.append(mount_info); }); } @@ -254,20 +254,20 @@ static void analyze(RefPtr tree, SpaceAnalyzer::TreeMapWidget& treemapwidg if (!error_accumulator.is_empty()) { StringBuilder builder; bool first = true; - builder.append("Some directories were not analyzed: "); + builder.append("Some directories were not analyzed: "sv); for (auto& key : error_accumulator.keys()) { if (!first) { - builder.append(", "); + builder.append(", "sv); } auto const* error = strerror(key); builder.append({ error, strlen(error) }); - builder.append(" ("); + builder.append(" ("sv); int value = error_accumulator.get(key).value(); builder.append(String::number(value)); if (value == 1) { - builder.append(" time"); + builder.append(" time"sv); } else { - builder.append(" times"); + builder.append(" times"sv); } builder.append(")"); first = false; @@ -308,7 +308,7 @@ ErrorOr serenity_main(Main::Arguments arguments) RefPtr tree = adopt_ref(*new Tree("")); // Configure application window. - auto app_icon = GUI::Icon::default_icon("app-space-analyzer"); + auto app_icon = GUI::Icon::default_icon("app-space-analyzer"sv); auto window = GUI::Window::construct(); window->set_title(APP_NAME); window->resize(640, 480); @@ -336,14 +336,14 @@ ErrorOr serenity_main(Main::Arguments arguments) help_menu.add_action(GUI::CommonActions::make_about_action(APP_NAME, app_icon, window)); // Configure the nodes context menu. - auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto open_folder_action = GUI::Action::create("Open Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol(get_absolute_path_to_selected_node(treemapwidget))); }); - auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto open_containing_folder_action = GUI::Action::create("Open Containing Folder", { Mod_Ctrl, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { LexicalPath path { get_absolute_path_to_selected_node(treemapwidget) }; Desktop::Launcher::open(URL::create_with_file_protocol(path.dirname(), path.basename())); }); - auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto copy_path_action = GUI::Action::create("Copy Path to Clipboard", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { GUI::Clipboard::the().set_plain_text(get_absolute_path_to_selected_node(treemapwidget)); }); auto delete_action = GUI::CommonActions::make_delete_action([&](auto&) { @@ -358,7 +358,7 @@ ErrorOr serenity_main(Main::Arguments arguments) String::formatted("Failed to delete \"{}\": {}. Retry?", deletion_result.error().file, static_cast(deletion_result.error())), - "Deletion failed", + "Deletion failed"sv, GUI::MessageBox::Type::Error, GUI::MessageBox::InputType::YesNo); if (retry_message_result == GUI::MessageBox::ExecResult::Yes) { @@ -367,7 +367,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } else { GUI::MessageBox::show(window, String::formatted("Successfully deleted \"{}\".", selected_node_path), - "Deletion completed", + "Deletion completed"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::OK); } diff --git a/Userland/Applications/Spreadsheet/Cell.cpp b/Userland/Applications/Spreadsheet/Cell.cpp index ae49b1b1a5a..1a0d6cabaed 100644 --- a/Userland/Applications/Spreadsheet/Cell.cpp +++ b/Userland/Applications/Spreadsheet/Cell.cpp @@ -74,10 +74,10 @@ CellType const& Cell::type() const if (m_kind == LiteralString) { if (m_data.to_int().has_value()) - return *CellType::get_by_name("Numeric"); + return *CellType::get_by_name("Numeric"sv); } - return *CellType::get_by_name("Identity"); + return *CellType::get_by_name("Identity"sv); } JS::ThrowCompletionOr Cell::typed_display() const diff --git a/Userland/Applications/Spreadsheet/CellType/Date.cpp b/Userland/Applications/Spreadsheet/CellType/Date.cpp index 9810f162d96..f74a5d5a1b4 100644 --- a/Userland/Applications/Spreadsheet/CellType/Date.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Date.cpp @@ -13,7 +13,7 @@ namespace Spreadsheet { DateCell::DateCell() - : CellType("Date") + : CellType("Date"sv) { } @@ -21,7 +21,7 @@ JS::ThrowCompletionOr DateCell::display(Cell& cell, CellTypeMetadata con { return propagate_failure(cell, [&]() -> JS::ThrowCompletionOr { auto timestamp = TRY(js_value(cell, metadata)); - auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(cell.sheet().global_object()))).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S" : metadata.format.characters()); + auto string = Core::DateTime::from_timestamp(TRY(timestamp.to_i32(cell.sheet().global_object()))).to_string(metadata.format.is_empty() ? "%Y-%m-%d %H:%M:%S"sv : metadata.format.view()); if (metadata.length >= 0) return string.substring(0, metadata.length); diff --git a/Userland/Applications/Spreadsheet/CellType/Identity.cpp b/Userland/Applications/Spreadsheet/CellType/Identity.cpp index b44c7c5802b..580f7b917a4 100644 --- a/Userland/Applications/Spreadsheet/CellType/Identity.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Identity.cpp @@ -11,7 +11,7 @@ namespace Spreadsheet { IdentityCell::IdentityCell() - : CellType("Identity") + : CellType("Identity"sv) { } diff --git a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp index 483c55d0b4e..33bda0507a9 100644 --- a/Userland/Applications/Spreadsheet/CellType/Numeric.cpp +++ b/Userland/Applications/Spreadsheet/CellType/Numeric.cpp @@ -13,7 +13,7 @@ namespace Spreadsheet { NumericCell::NumericCell() - : CellType("Numeric") + : CellType("Numeric"sv) { } diff --git a/Userland/Applications/Spreadsheet/CellType/String.cpp b/Userland/Applications/Spreadsheet/CellType/String.cpp index c0707be469e..8a066bbfe55 100644 --- a/Userland/Applications/Spreadsheet/CellType/String.cpp +++ b/Userland/Applications/Spreadsheet/CellType/String.cpp @@ -11,7 +11,7 @@ namespace Spreadsheet { StringCell::StringCell() - : CellType("String") + : CellType("String"sv) { } diff --git a/Userland/Applications/Spreadsheet/ExportDialog.cpp b/Userland/Applications/Spreadsheet/ExportDialog.cpp index 502e9be0b2d..6f5cd8c8f70 100644 --- a/Userland/Applications/Spreadsheet/ExportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ExportDialog.cpp @@ -26,7 +26,7 @@ #include // This is defined in ImportDialog.cpp, we can't include it twice, since the generated symbol is exported. -extern char const select_format_page_gml[]; +extern StringView select_format_page_gml; namespace Spreadsheet { @@ -245,7 +245,7 @@ Result ExportDialog::make_and_run_for(StringView mime, Core::File& { auto wizard = GUI::WizardDialog::construct(GUI::Application::the()->active_window()); wizard->set_title("File Export Wizard"); - wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet").bitmap_for_size(16)); + wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16)); auto export_xsv = [&]() -> Result { // FIXME: Prompt for the user to select a specific sheet to export @@ -283,7 +283,7 @@ Result ExportDialog::make_and_run_for(StringView mime, Core::File& auto const* error = strerror(error_number); StringBuilder sb; - sb.append("Unable to save file. Error: "); + sb.append("Unable to save file. Error: "sv); sb.append({ error, strlen(error) }); return sb.to_string(); diff --git a/Userland/Applications/Spreadsheet/HelpWindow.cpp b/Userland/Applications/Spreadsheet/HelpWindow.cpp index 6a9f5eb71e9..4ee6d5089ca 100644 --- a/Userland/Applications/Spreadsheet/HelpWindow.cpp +++ b/Userland/Applications/Spreadsheet/HelpWindow.cpp @@ -65,7 +65,7 @@ HelpWindow::HelpWindow(GUI::Window* parent) { resize(530, 365); set_title("Spreadsheet Functions Help"); - set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors()); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors()); set_accessory(true); auto& widget = set_main_widget(); @@ -93,7 +93,7 @@ HelpWindow::HelpWindow(GUI::Window* parent) auto& doc = doc_option.as_object(); const auto& name = url.fragment(); - auto* example_data_ptr = doc.get_ptr("example_data"); + auto* example_data_ptr = doc.get_ptr("example_data"sv); if (!example_data_ptr || !example_data_ptr->is_object()) { GUI::MessageBox::show_error(this, String::formatted("No example data found for '{}'", url.path())); return; @@ -143,47 +143,47 @@ String HelpWindow::render(StringView key) VERIFY(m_docs.has_object(key)); auto& doc = m_docs.get(key).as_object(); - auto name = doc.get("name").to_string(); - auto argc = doc.get("argc").to_u32(0); - VERIFY(doc.has_array("argnames")); - auto& argnames = doc.get("argnames").as_array(); + auto name = doc.get("name"sv).to_string(); + auto argc = doc.get("argc"sv).to_u32(0); + VERIFY(doc.has_array("argnames"sv)); + auto& argnames = doc.get("argnames"sv).as_array(); - auto docstring = doc.get("doc").to_string(); + auto docstring = doc.get("doc"sv).to_string(); StringBuilder markdown_builder; - markdown_builder.append("# NAME\n`"); + markdown_builder.append("# NAME\n`"sv); markdown_builder.append(name); - markdown_builder.append("`\n\n"); + markdown_builder.append("`\n\n"sv); - markdown_builder.append("# ARGUMENTS\n"); + markdown_builder.append("# ARGUMENTS\n"sv); if (argc > 0) markdown_builder.appendff("{} required argument(s):\n", argc); else - markdown_builder.append("No required arguments.\n"); + markdown_builder.append("No required arguments.\n"sv); for (size_t i = 0; i < argc; ++i) markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string()); if (argc > 0) - markdown_builder.append("\n"); + markdown_builder.append("\n"sv); if ((size_t)argnames.size() > argc) { auto opt_count = argnames.size() - argc; markdown_builder.appendff("{} optional argument(s):\n", opt_count); for (size_t i = argc; i < (size_t)argnames.size(); ++i) markdown_builder.appendff("- `{}`\n", argnames.at(i).to_string()); - markdown_builder.append("\n"); + markdown_builder.append("\n"sv); } - markdown_builder.append("# DESCRIPTION\n"); + markdown_builder.append("# DESCRIPTION\n"sv); markdown_builder.append(docstring); - markdown_builder.append("\n\n"); + markdown_builder.append("\n\n"sv); - if (doc.has("examples")) { - auto& examples = doc.get("examples"); + if (doc.has("examples"sv)) { + auto& examples = doc.get("examples"sv); VERIFY(examples.is_object()); - markdown_builder.append("# EXAMPLES\n"); + markdown_builder.append("# EXAMPLES\n"sv); examples.as_object().for_each_member([&](auto& text, auto& description_value) { dbgln("```js\n{}\n```\n\n- {}\n", text, description_value.to_string()); markdown_builder.appendff("```js\n{}\n```\n\n- {}\n", text, description_value.to_string()); diff --git a/Userland/Applications/Spreadsheet/ImportDialog.cpp b/Userland/Applications/Spreadsheet/ImportDialog.cpp index 3b5c794f65a..7382f6f2bd1 100644 --- a/Userland/Applications/Spreadsheet/ImportDialog.cpp +++ b/Userland/Applications/Spreadsheet/ImportDialog.cpp @@ -179,7 +179,7 @@ Result, String> ImportDialog::make_and_run_for(GUI::W { auto wizard = GUI::WizardDialog::construct(&parent); wizard->set_title("File Import Wizard"); - wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet").bitmap_for_size(16)); + wizard->set_icon(GUI::Icon::default_icon("app-spreadsheet"sv).bitmap_for_size(16)); auto import_xsv = [&]() -> Result, String> { auto contents = file.read_all(); @@ -212,7 +212,7 @@ Result, String> ImportDialog::make_and_run_for(GUI::W auto json_value_option = JsonParser(file.read_all()).parse(); if (json_value_option.is_error()) { StringBuilder sb; - sb.append("Failed to parse "); + sb.append("Failed to parse "sv); sb.append(file.filename()); return sb.to_string(); @@ -221,7 +221,7 @@ Result, String> ImportDialog::make_and_run_for(GUI::W auto& json_value = json_value_option.value(); if (!json_value.is_array()) { StringBuilder sb; - sb.append("Did not find a spreadsheet in "); + sb.append("Did not find a spreadsheet in "sv); sb.append(file.filename()); return sb.to_string(); diff --git a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp index 0103e4c6c04..82a0df5ab31 100644 --- a/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/Test/TestXSV.cpp @@ -18,29 +18,29 @@ TEST_CASE(should_parse_valid_data) auto data = R"~~~(Foo, Bar, Baz 1, 2, 3 4, 5, 6 - """x", y"z, 9)~~~"; + """x", y"z, 9)~~~"sv; auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces }; csv.parse(); EXPECT(!csv.has_error()); - EXPECT_EQ(csv[0]["Foo"], "1"); - EXPECT_EQ(csv[2]["Foo"], "\"x"); - EXPECT_EQ(csv[2]["Bar"], "y\"z"); + EXPECT_EQ(csv[0]["Foo"sv], "1"sv); + EXPECT_EQ(csv[2]["Foo"sv], "\"x"sv); + EXPECT_EQ(csv[2]["Bar"sv], "y\"z"sv); } { auto data = R"~~~(Foo, Bar, Baz 1 , 2, 3 4, "5 " , 6 - """x", y"z, 9 )~~~"; + """x", y"z, 9 )~~~"sv; auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces | Reader::ParserBehavior::TrimTrailingFieldSpaces }; csv.parse(); EXPECT(!csv.has_error()); - EXPECT_EQ(csv[0]["Foo"], "1"); - EXPECT_EQ(csv[1]["Bar"], "5 "); - EXPECT_EQ(csv[2]["Foo"], "\"x"); - EXPECT_EQ(csv[2]["Baz"], "9"); + EXPECT_EQ(csv[0]["Foo"sv], "1"sv); + EXPECT_EQ(csv[1]["Bar"sv], "5 "sv); + EXPECT_EQ(csv[2]["Foo"sv], "\"x"sv); + EXPECT_EQ(csv[2]["Baz"sv], "9"sv); } } @@ -48,7 +48,7 @@ TEST_CASE(should_fail_nicely) { { auto data = R"~~~(Foo, Bar, Baz - x, y)~~~"; + x, y)~~~"sv; auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces }; csv.parse(); EXPECT(csv.has_error()); @@ -57,7 +57,7 @@ TEST_CASE(should_fail_nicely) { auto data = R"~~~(Foo, Bar, Baz - x, y, "z)~~~"; + x, y, "z)~~~"sv; auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces }; csv.parse(); EXPECT(csv.has_error()); @@ -70,7 +70,7 @@ TEST_CASE(should_iterate_rows) auto data = R"~~~(Foo, Bar, Baz 1, 2, 3 4, 5, 6 - """x", y"z, 9)~~~"; + """x", y"z, 9)~~~"sv; auto csv = Reader::CSV { data, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders | Reader::ParserBehavior::TrimLeadingFieldSpaces }; csv.parse(); EXPECT(!csv.has_error()); @@ -93,7 +93,7 @@ BENCHMARK_CASE(fairly_big_data) memcpy(buf.offset_pointer(row * line.length()), line.characters_without_null_termination(), line.length()); } - auto csv = Reader::CSV { (char const*)buf.data(), Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders }; + auto csv = Reader::CSV { StringView { buf.bytes() }, Reader::default_behaviors() | Reader::ParserBehavior::ReadHeaders }; csv.parse(); EXPECT(!csv.has_error()); diff --git a/Userland/Applications/Spreadsheet/Readers/XSV.cpp b/Userland/Applications/Spreadsheet/Readers/XSV.cpp index 41707431951..6a1533aabd1 100644 --- a/Userland/Applications/Spreadsheet/Readers/XSV.cpp +++ b/Userland/Applications/Spreadsheet/Readers/XSV.cpp @@ -133,7 +133,7 @@ Vector XSV::read_row(bool header_row) XSV::Field XSV::read_one_field() { if ((m_behaviors & ParserBehavior::TrimLeadingFieldSpaces) != ParserBehavior::None) - m_lexer.consume_while(is_any_of(" \t\v")); + m_lexer.consume_while(is_any_of(" \t\v"sv)); bool is_quoted = false; Field field; @@ -145,7 +145,7 @@ XSV::Field XSV::read_one_field() } if ((m_behaviors & ParserBehavior::TrimTrailingFieldSpaces) != ParserBehavior::None) { - m_lexer.consume_while(is_any_of(" \t\v")); + m_lexer.consume_while(is_any_of(" \t\v"sv)); if (!is_quoted) { // Also have to trim trailing spaces from unquoted fields. diff --git a/Userland/Applications/Spreadsheet/Spreadsheet.cpp b/Userland/Applications/Spreadsheet/Spreadsheet.cpp index 1cebe1a0558..18de0263741 100644 --- a/Userland/Applications/Spreadsheet/Spreadsheet.cpp +++ b/Userland/Applications/Spreadsheet/Spreadsheet.cpp @@ -48,7 +48,7 @@ Sheet::Sheet(Workbook& workbook) global_object().define_direct_property("thisSheet", &global_object(), JS::default_attributes); // Self-reference is unfortunate, but required. // Sadly, these have to be evaluated once per sheet. - constexpr StringView runtime_file_path = "/res/js/Spreadsheet/runtime.js"; + constexpr auto runtime_file_path = "/res/js/Spreadsheet/runtime.js"sv; auto file_or_error = Core::File::open(runtime_file_path, Core::OpenMode::ReadOnly); if (!file_or_error.is_error()) { auto buffer = file_or_error.value()->read_all(); @@ -94,7 +94,7 @@ size_t Sheet::add_row() static Optional convert_from_string(StringView str, unsigned base = 26, StringView map = {}) { if (map.is_null()) - map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + map = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"sv; VERIFY(base >= 2 && base <= map.length()); @@ -375,10 +375,10 @@ Vector Sheet::copy_cells(Vector from, Vector to, RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) { auto sheet = adopt_ref(*new Sheet(workbook)); - auto rows = object.get("rows").to_u32(default_row_count); - auto columns = object.get("columns"); - auto name = object.get("name").as_string_or("Sheet"); - if (object.has("cells") && !object.has_object("cells")) + auto rows = object.get("rows"sv).to_u32(default_row_count); + auto columns = object.get("columns"sv); + auto name = object.get("name"sv).as_string_or("Sheet"); + if (object.has("cells"sv) && !object.has_object("cells"sv)) return {}; sheet->set_name(name); @@ -403,51 +403,51 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) auto& parse_function = json.as_object().get_without_side_effects("parse").as_function(); auto read_format = [](auto& format, auto const& obj) { - if (auto value = obj.get("foreground_color"); value.is_string()) + if (auto value = obj.get("foreground_color"sv); value.is_string()) format.foreground_color = Color::from_string(value.as_string()); - if (auto value = obj.get("background_color"); value.is_string()) + if (auto value = obj.get("background_color"sv); value.is_string()) format.background_color = Color::from_string(value.as_string()); }; - if (object.has_object("cells")) { - object.get("cells").as_object().for_each_member([&](auto& name, JsonValue const& value) { + if (object.has_object("cells"sv)) { + object.get("cells"sv).as_object().for_each_member([&](auto& name, JsonValue const& value) { auto position_option = sheet->parse_cell_name(name); if (!position_option.has_value()) return IterationDecision::Continue; auto position = position_option.value(); auto& obj = value.as_object(); - auto kind = obj.get("kind").as_string_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula; + auto kind = obj.get("kind"sv).as_string_or("LiteralString") == "LiteralString" ? Cell::LiteralString : Cell::Formula; OwnPtr cell; switch (kind) { case Cell::LiteralString: - cell = make(obj.get("value").to_string(), position, *sheet); + cell = make(obj.get("value"sv).to_string(), position, *sheet); break; case Cell::Formula: { auto& interpreter = sheet->interpreter(); - auto value_or_error = JS::call(interpreter.global_object(), parse_function, json, JS::js_string(interpreter.heap(), obj.get("value").as_string())); + auto value_or_error = JS::call(interpreter.global_object(), parse_function, json, JS::js_string(interpreter.heap(), obj.get("value"sv).as_string())); if (value_or_error.is_error()) { warnln("Failed to load previous value for cell {}, leaving as undefined", position.to_cell_identifier(sheet)); value_or_error = JS::js_undefined(); } - cell = make(obj.get("source").to_string(), value_or_error.release_value(), position, *sheet); + cell = make(obj.get("source"sv).to_string(), value_or_error.release_value(), position, *sheet); break; } } - auto type_name = obj.has("type") ? obj.get("type").to_string() : "Numeric"; + auto type_name = obj.has("type"sv) ? obj.get("type"sv).to_string() : "Numeric"; cell->set_type(type_name); - auto type_meta = obj.get("type_metadata"); + auto type_meta = obj.get("type_metadata"sv); if (type_meta.is_object()) { auto& meta_obj = type_meta.as_object(); auto meta = cell->type_metadata(); - if (auto value = meta_obj.get("length"); value.is_number()) + if (auto value = meta_obj.get("length"sv); value.is_number()) meta.length = value.to_i32(); - if (auto value = meta_obj.get("format"); value.is_string()) + if (auto value = meta_obj.get("format"sv); value.is_string()) meta.format = value.as_string(); - if (auto value = meta_obj.get("alignment"); value.is_string()) { + if (auto value = meta_obj.get("alignment"sv); value.is_string()) { auto alignment = Gfx::text_alignment_from_string(value.as_string()); if (alignment.has_value()) meta.alignment = alignment.value(); @@ -457,7 +457,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) cell->set_type_metadata(move(meta)); } - auto conditional_formats = obj.get("conditional_formats"); + auto conditional_formats = obj.get("conditional_formats"sv); auto cformats = cell->conditional_formats(); if (conditional_formats.is_array()) { conditional_formats.as_array().for_each([&](const auto& fmt_val) { @@ -465,7 +465,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) return IterationDecision::Continue; auto& fmt_obj = fmt_val.as_object(); - auto fmt_cond = fmt_obj.get("condition").to_string(); + auto fmt_cond = fmt_obj.get("condition"sv).to_string(); if (fmt_cond.is_empty()) return IterationDecision::Continue; @@ -479,7 +479,7 @@ RefPtr Sheet::from_json(JsonObject const& object, Workbook& workbook) cell->set_conditional_formats(move(cformats)); } - auto evaluated_format = obj.get("evaluated_formats"); + auto evaluated_format = obj.get("evaluated_formats"sv); if (evaluated_format.is_object()) { auto& evaluated_format_obj = evaluated_format.as_object(); auto& evaluated_fmts = cell->evaluated_formats(); @@ -722,8 +722,8 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu return String::formatted("{}(...???{})", function, argument_index); auto& entry_object = entry.as_object(); - size_t argc = entry_object.get("argc").to_int(0); - auto argnames_value = entry_object.get("argnames"); + size_t argc = entry_object.get("argc"sv).to_int(0); + auto argnames_value = entry_object.get("argnames"sv); if (!argnames_value.is_array()) return String::formatted("{}(...{}???{})", function, argc, argument_index); auto& argnames = argnames_value.as_array(); @@ -731,7 +731,7 @@ String Sheet::generate_inline_documentation_for(StringView function, size_t argu builder.appendff("{}(", function); for (size_t i = 0; i < (size_t)argnames.size(); ++i) { if (i != 0 && i < (size_t)argnames.size()) - builder.append(", "); + builder.append(", "sv); if (i == argument_index) builder.append('<'); else if (i >= argc) diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp index 3d496c6ad38..dfa11afd00f 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.cpp @@ -121,12 +121,12 @@ GUI::Variant SheetModel::data(const GUI::ModelIndex& index, GUI::ModelRole role) StringBuilder builder; builder.appendff("{}\n", error.get_without_side_effects(object.vm().names.message).to_string_without_side_effects()); for (auto const& frame : trace.in_reverse()) { - if (frame.source_range.filename.contains("runtime.js")) { + if (frame.source_range.filename.contains("runtime.js"sv)) { if (frame.function_name == "") builder.appendff(" in a builtin function at line {}, column {}\n", frame.source_range.start.line, frame.source_range.start.column); else builder.appendff(" while evaluating builtin '{}'\n", frame.function_name); - } else if (frame.source_range.filename.starts_with("cell ")) { + } else if (frame.source_range.filename.starts_with("cell "sv)) { builder.appendff(" in cell '{}', at line {}, column {}\n", frame.source_range.filename.substring_view(5), frame.source_range.start.line, frame.source_range.start.column); } } diff --git a/Userland/Applications/Spreadsheet/SpreadsheetModel.h b/Userland/Applications/Spreadsheet/SpreadsheetModel.h index a54b210405c..8cdabde0303 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetModel.h +++ b/Userland/Applications/Spreadsheet/SpreadsheetModel.h @@ -29,7 +29,7 @@ public: virtual bool is_editable(const GUI::ModelIndex&) const override; virtual void set_data(const GUI::ModelIndex&, const GUI::Variant&) override; virtual bool is_column_sortable(int) const override { return false; } - virtual StringView drag_data_type() const override { return "text/x-spreadsheet-data"; } + virtual StringView drag_data_type() const override { return "text/x-spreadsheet-data"sv; } Sheet& sheet() { return *m_sheet; } void update(); diff --git a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp index a7fa639f3f7..822a4a150e5 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetWidget.cpp @@ -43,12 +43,12 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe current_cell_label.set_fixed_width(50); auto& help_button = top_bar.add(""); - help_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors()); + help_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors()); help_button.set_tooltip("Functions Help"); help_button.set_fixed_size(20, 20); help_button.on_click = [&](auto) { if (!current_view()) { - GUI::MessageBox::show_error(window(), "Can only show function documentation/help when a worksheet exists and is open"); + GUI::MessageBox::show_error(window(), "Can only show function documentation/help when a worksheet exists and is open"sv); } else if (auto* sheet_ptr = current_worksheet_if_available()) { auto docs = sheet_ptr->gather_documentation(); auto help_window = HelpWindow::the(window()); @@ -88,7 +88,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe m_inline_documentation_label->set_text_alignment(Gfx::TextAlignment::CenterLeft); if (!m_workbook->has_sheets() && should_add_sheet_if_empty) - m_workbook->add_sheet("Sheet 1"); + m_workbook->add_sheet("Sheet 1"sv); m_tab_context_menu = GUI::Menu::construct(); m_rename_action = GUI::CommonActions::make_rename_action([this](auto&) { @@ -98,16 +98,16 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe VERIFY(sheet_ptr); // How did we get here without a sheet? auto& sheet = *sheet_ptr; String new_name; - if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet") == GUI::Dialog::ExecResult::OK) { + if (GUI::InputBox::show(window(), new_name, String::formatted("New name for '{}'", sheet.name()), "Rename sheet"sv) == GUI::Dialog::ExecResult::OK) { sheet.set_name(new_name); sheet.update(); m_tab_widget->set_tab_title(static_cast(*m_tab_context_menu_sheet_view), new_name); } }); m_tab_context_menu->add_action(*m_rename_action); - m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_tab_context_menu->add_action(GUI::Action::create("Add new sheet...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { String name; - if (GUI::InputBox::show(window(), name, "Name for new sheet", "Create sheet") == GUI::Dialog::ExecResult::OK) { + if (GUI::InputBox::show(window(), name, "Name for new sheet"sv, "Create sheet"sv) == GUI::Dialog::ExecResult::OK) { NonnullRefPtrVector new_sheets; new_sheets.append(m_workbook->add_sheet(name)); setup_tabs(move(new_sheets)); @@ -116,7 +116,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe setup_tabs(m_workbook->sheets()); - m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_new_action = GUI::Action::create("Add New Sheet", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new-tab.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { add_sheet(); }); @@ -172,7 +172,7 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe auto* worksheet_ptr = current_worksheet_if_available(); if (!worksheet_ptr) { - GUI::MessageBox::show_error(window(), "There are no active worksheets"); + GUI::MessageBox::show_error(window(), "There are no active worksheets"sv); return; } auto& sheet = *worksheet_ptr; @@ -225,19 +225,19 @@ SpreadsheetWidget::SpreadsheetWidget(GUI::Window& parent_window, NonnullRefPtrVe m_redo_action->set_enabled(false); m_functions_help_action = GUI::Action::create( - "&Functions Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + "&Functions Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { if (auto* worksheet_ptr = current_worksheet_if_available()) { auto docs = worksheet_ptr->gather_documentation(); auto help_window = Spreadsheet::HelpWindow::the(window()); help_window->set_docs(move(docs)); help_window->show(); } else { - GUI::MessageBox::show_error(window(), "Cannot prepare documentation/help without an active worksheet"); + GUI::MessageBox::show_error(window(), "Cannot prepare documentation/help without an active worksheet"sv); } }, window()); - m_about_action = GUI::CommonActions::make_about_action("Spreadsheet", GUI::Icon::default_icon("app-spreadsheet"), window()); + m_about_action = GUI::CommonActions::make_about_action("Spreadsheet", GUI::Icon::default_icon("app-spreadsheet"sv), window()); toolbar.add_action(*m_new_action); toolbar.add_action(*m_open_action); @@ -279,7 +279,7 @@ void SpreadsheetWidget::resize_event(GUI::ResizeEvent& event) void SpreadsheetWidget::clipboard_content_did_change(String const& mime_type) { if (auto* sheet = current_worksheet_if_available()) - m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/")); + m_paste_action->set_enabled(!sheet->selected_cells().is_empty() && mime_type.starts_with("text/"sv)); } void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) @@ -303,7 +303,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) VERIFY(!selection.is_empty()); m_cut_action->set_enabled(true); m_copy_action->set_enabled(true); - m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/")); + m_paste_action->set_enabled(GUI::Clipboard::the().fetch_mime_type().starts_with("text/"sv)); m_current_cell_label->set_enabled(true); m_cell_value_editor->set_enabled(true); @@ -338,7 +338,7 @@ void SpreadsheetWidget::setup_tabs(NonnullRefPtrVector new_sheets) auto& first_cell = cells.first(); m_cell_value_editor->on_change = nullptr; - m_cell_value_editor->set_text(""); + m_cell_value_editor->set_text(""sv); m_should_change_selected_cells = false; m_cell_value_editor->on_focusin = [this] { m_should_change_selected_cells = true; }; m_cell_value_editor->on_focusout = [this] { m_should_change_selected_cells = false; }; @@ -500,7 +500,7 @@ bool SpreadsheetWidget::request_close() void SpreadsheetWidget::add_sheet() { StringBuilder name; - name.append("Sheet"); + name.append("Sheet"sv); name.appendff(" {}", m_workbook->sheets().size() + 1); NonnullRefPtrVector new_sheets; @@ -522,10 +522,10 @@ void SpreadsheetWidget::update_window_title() { StringBuilder builder; if (current_filename().is_empty()) - builder.append("Untitled"); + builder.append("Untitled"sv); else builder.append(current_filename()); - builder.append("[*] - Spreadsheet"); + builder.append("[*] - Spreadsheet"sv); window()->set_title(builder.to_string()); } @@ -538,14 +538,14 @@ void SpreadsheetWidget::clipboard_action(bool is_cut) /// - selected cell+ auto* worksheet_ptr = current_worksheet_if_available(); if (!worksheet_ptr) { - GUI::MessageBox::show_error(window(), "There are no active worksheets"); + GUI::MessageBox::show_error(window(), "There are no active worksheets"sv); return; } auto& worksheet = *worksheet_ptr; auto& cells = worksheet.selected_cells(); VERIFY(!cells.is_empty()); StringBuilder text_builder, url_builder; - url_builder.append(is_cut ? "cut\n" : "copy\n"); + url_builder.append(is_cut ? "cut\n"sv : "copy\n"sv); bool first = true; auto cursor = current_selection_cursor(); if (cursor) { diff --git a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp index fd294d3a0c7..0e356a5ba00 100644 --- a/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp +++ b/Userland/Applications/Spreadsheet/Writers/Test/TestXSVWriter.cpp @@ -42,7 +42,7 @@ TEST_CASE(can_write_with_header) auto buffer = ByteBuffer::create_uninitialized(1024).release_value(); OutputMemoryStream stream { buffer }; - Writer::CSV csv(stream, data, { "A", "B\"", "C" }); + Writer::CSV csv(stream, data, { "A"sv, "B\""sv, "C"sv }); auto expected_output = R"~(A,"B""",C 1,2,3 @@ -63,7 +63,7 @@ TEST_CASE(can_write_with_different_behaviors) auto buffer = ByteBuffer::create_uninitialized(1024).release_value(); OutputMemoryStream stream { buffer }; - Writer::CSV csv(stream, data, { "A", "B\"", "C" }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders); + Writer::CSV csv(stream, data, { "A"sv, "B\""sv, "C"sv }, Writer::WriterBehavior::QuoteOnlyInFieldStart | Writer::WriterBehavior::WriteHeaders); auto expected_output = R"~(A,B",C Well,Hello",Friends diff --git a/Userland/Applications/Spreadsheet/main.cpp b/Userland/Applications/Spreadsheet/main.cpp index 53408b712be..24bf2436671 100644 --- a/Userland/Applications/Spreadsheet/main.cpp +++ b/Userland/Applications/Spreadsheet/main.cpp @@ -48,11 +48,11 @@ ErrorOr serenity_main(Main::Arguments arguments) // For writing temporary files when exporting. TRY(Core::System::unveil("/tmp", "crw")); TRY(Core::System::unveil("/etc", "r")); - TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "rwc")); + TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "rwc"sv)); TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-spreadsheet"); + auto app_icon = GUI::Icon::default_icon("app-spreadsheet"sv); auto window = GUI::Window::construct(); window->resize(640, 480); window->set_icon(app_icon.bitmap_for_size(16)); diff --git a/Userland/Applications/SystemMonitor/GraphWidget.cpp b/Userland/Applications/SystemMonitor/GraphWidget.cpp index 73296c2502c..db06da11d43 100644 --- a/Userland/Applications/SystemMonitor/GraphWidget.cpp +++ b/Userland/Applications/SystemMonitor/GraphWidget.cpp @@ -153,8 +153,8 @@ void GraphWidget::paint_event(GUI::PaintEvent& event) text_rect.set_height(font().glyph_height()); auto text = format.text_formatter(current_values[i]); if (format.text_shadow_color != Color::Transparent) - painter.draw_text(text_rect.translated(1, 1), text.characters(), Gfx::TextAlignment::CenterRight, format.text_shadow_color); - painter.draw_text(text_rect, text.characters(), Gfx::TextAlignment::CenterRight, graph_color); + painter.draw_text(text_rect.translated(1, 1), text, Gfx::TextAlignment::CenterRight, format.text_shadow_color); + painter.draw_text(text_rect, text, Gfx::TextAlignment::CenterRight, graph_color); y += text_rect.height() + 4; } } diff --git a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp index 9db1d5d9745..0b162e5bb80 100644 --- a/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Userland/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -114,16 +114,16 @@ void MemoryStatsWidget::refresh() auto json_result = JsonValue::from_string(file_contents).release_value_but_fixme_should_propagate_errors(); auto const& json = json_result.as_object(); - u32 kmalloc_allocated = json.get("kmalloc_allocated").to_u32(); - u32 kmalloc_available = json.get("kmalloc_available").to_u32(); - u64 user_physical_allocated = json.get("user_physical_allocated").to_u64(); - u64 user_physical_available = json.get("user_physical_available").to_u64(); - u64 user_physical_committed = json.get("user_physical_committed").to_u64(); - u64 user_physical_uncommitted = json.get("user_physical_uncommitted").to_u64(); - u64 super_physical_alloc = json.get("super_physical_allocated").to_u64(); - u64 super_physical_free = json.get("super_physical_available").to_u64(); - u32 kmalloc_call_count = json.get("kmalloc_call_count").to_u32(); - u32 kfree_call_count = json.get("kfree_call_count").to_u32(); + u32 kmalloc_allocated = json.get("kmalloc_allocated"sv).to_u32(); + u32 kmalloc_available = json.get("kmalloc_available"sv).to_u32(); + u64 user_physical_allocated = json.get("user_physical_allocated"sv).to_u64(); + u64 user_physical_available = json.get("user_physical_available"sv).to_u64(); + u64 user_physical_committed = json.get("user_physical_committed"sv).to_u64(); + u64 user_physical_uncommitted = json.get("user_physical_uncommitted"sv).to_u64(); + u64 super_physical_alloc = json.get("super_physical_allocated"sv).to_u64(); + u64 super_physical_free = json.get("super_physical_available"sv).to_u64(); + u32 kmalloc_call_count = json.get("kmalloc_call_count"sv).to_u32(); + u32 kfree_call_count = json.get("kfree_call_count"sv).to_u32(); u64 kmalloc_bytes_total = kmalloc_allocated + kmalloc_available; u64 user_physical_pages_total = user_physical_allocated + user_physical_available; diff --git a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp index 8518a06f81d..5317ae04ba4 100644 --- a/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp +++ b/Userland/Applications/SystemMonitor/NetworkStatisticsWidget.cpp @@ -24,8 +24,8 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() layout()->set_margins(4); set_fill_with_background_color(true); - m_network_connected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-connected.png").release_value_but_fixme_should_propagate_errors(); - m_network_disconnected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png").release_value_but_fixme_should_propagate_errors(); + m_network_connected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-connected.png"sv).release_value_but_fixme_should_propagate_errors(); + m_network_disconnected_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/network-disconnected.png"sv).release_value_but_fixme_should_propagate_errors(); m_network_link_down_bitmap = Gfx::Bitmap::try_create(m_network_connected_bitmap->format(), m_network_connected_bitmap->size()).release_value_but_fixme_should_propagate_errors(); { @@ -35,7 +35,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() }); } - auto& adapters_group_box = add("Adapters"); + auto& adapters_group_box = add("Adapters"sv); adapters_group_box.set_layout(); adapters_group_box.layout()->set_margins(6); adapters_group_box.set_fixed_height(120); @@ -45,25 +45,25 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() Vector net_adapters_fields; net_adapters_fields.empend("", Gfx::TextAlignment::CenterLeft, [this](JsonObject const& object) -> GUI::Variant { - if (!object.get("link_up").as_bool()) + if (!object.get("link_up"sv).as_bool()) return *m_network_link_down_bitmap; else - return object.get("ipv4_address").as_string_or("").is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap; + return object.get("ipv4_address"sv).as_string_or(""sv).is_empty() ? *m_network_disconnected_bitmap : *m_network_connected_bitmap; }); net_adapters_fields.empend("name", "Name", Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("class_name", "Class", Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("mac_address", "MAC", Gfx::TextAlignment::CenterLeft); net_adapters_fields.empend("Link status", Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> String { - if (!object.get("link_up").as_bool()) + if (!object.get("link_up"sv).as_bool()) return "Down"; - return String::formatted("{} Mb/s {}-duplex", object.get("link_speed").to_i32(), - object.get("link_full_duplex").as_bool() ? "full" : "half"); + return String::formatted("{} Mb/s {}-duplex", object.get("link_speed"sv).to_i32(), + object.get("link_full_duplex"sv).as_bool() ? "full"sv : "half"sv); }); net_adapters_fields.empend("IPv4", Gfx::TextAlignment::CenterLeft, [](JsonObject const& object) -> String { - return object.get("ipv4_address").as_string_or(""); + return object.get("ipv4_address"sv).as_string_or(""sv); }); net_adapters_fields.empend("packets_in", "Pkt In", Gfx::TextAlignment::CenterRight); net_adapters_fields.empend("packets_out", "Pkt Out", Gfx::TextAlignment::CenterRight); @@ -72,7 +72,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() m_adapter_model = GUI::JsonArrayModel::create("/proc/net/adapters", move(net_adapters_fields)); m_adapter_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_adapter_model))); - auto& tcp_sockets_group_box = add("TCP Sockets"); + auto& tcp_sockets_group_box = add("TCP Sockets"sv); tcp_sockets_group_box.set_layout(); tcp_sockets_group_box.layout()->set_margins(6); @@ -93,7 +93,7 @@ NetworkStatisticsWidget::NetworkStatisticsWidget() m_tcp_socket_model = GUI::JsonArrayModel::create("/proc/net/tcp", move(net_tcp_fields)); m_tcp_socket_table_view->set_model(MUST(GUI::SortingProxyModel::create(*m_tcp_socket_model))); - auto& udp_sockets_group_box = add("UDP Sockets"); + auto& udp_sockets_group_box = add("UDP Sockets"sv); udp_sockets_group_box.set_layout(); udp_sockets_group_box.layout()->set_margins(6); diff --git a/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp index 41316327632..ba128886904 100644 --- a/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessFileDescriptorMapWidget.cpp @@ -27,19 +27,19 @@ ProcessFileDescriptorMapWidget::ProcessFileDescriptorMapWidget() pid_fds_fields.empend("offset", "Offset", Gfx::TextAlignment::CenterRight); pid_fds_fields.empend("absolute_path", "Path", Gfx::TextAlignment::CenterLeft); pid_fds_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) { - return object.get("seekable").to_bool() ? "Seekable" : "Sequential"; + return object.get("seekable"sv).to_bool() ? "Seekable" : "Sequential"; }); pid_fds_fields.empend("Blocking", Gfx::TextAlignment::CenterLeft, [](auto& object) { - return object.get("blocking").to_bool() ? "Blocking" : "Nonblocking"; + return object.get("blocking"sv).to_bool() ? "Blocking" : "Nonblocking"; }); pid_fds_fields.empend("On exec", Gfx::TextAlignment::CenterLeft, [](auto& object) { - return object.get("cloexec").to_bool() ? "Close" : "Keep"; + return object.get("cloexec"sv).to_bool() ? "Close" : "Keep"; }); pid_fds_fields.empend("Can read", Gfx::TextAlignment::CenterLeft, [](auto& object) { - return object.get("can_read").to_bool() ? "Yes" : "No"; + return object.get("can_read"sv).to_bool() ? "Yes" : "No"; }); pid_fds_fields.empend("Can write", Gfx::TextAlignment::CenterLeft, [](auto& object) { - return object.get("can_write").to_bool() ? "Yes" : "No"; + return object.get("can_write"sv).to_bool() ? "Yes" : "No"; }); m_model = GUI::JsonArrayModel::create({}, move(pid_fds_fields)); diff --git a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp index f25c17cf98a..6625397af66 100644 --- a/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp +++ b/Userland/Applications/SystemMonitor/ProcessMemoryMapWidget.cpp @@ -57,35 +57,35 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() Vector pid_vm_fields; pid_vm_fields.empend( "Address", Gfx::TextAlignment::CenterLeft, - [](auto& object) { return String::formatted("{:p}", object.get("address").to_u64()); }, - [](auto& object) { return object.get("address").to_u64(); }); + [](auto& object) { return String::formatted("{:p}", object.get("address"sv).to_u64()); }, + [](auto& object) { return object.get("address"sv).to_u64(); }); pid_vm_fields.empend("size", "Size", Gfx::TextAlignment::CenterRight); pid_vm_fields.empend("amount_resident", "Resident", Gfx::TextAlignment::CenterRight); pid_vm_fields.empend("amount_dirty", "Dirty", Gfx::TextAlignment::CenterRight); pid_vm_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](auto& object) { StringBuilder builder; - if (object.get("readable").to_bool()) + if (object.get("readable"sv).to_bool()) builder.append('R'); - if (object.get("writable").to_bool()) + if (object.get("writable"sv).to_bool()) builder.append('W'); - if (object.get("executable").to_bool()) + if (object.get("executable"sv).to_bool()) builder.append('X'); - if (object.get("shared").to_bool()) + if (object.get("shared"sv).to_bool()) builder.append('S'); - if (object.get("syscall").to_bool()) + if (object.get("syscall"sv).to_bool()) builder.append('C'); - if (object.get("stack").to_bool()) + if (object.get("stack"sv).to_bool()) builder.append('T'); return builder.to_string(); }); pid_vm_fields.empend("VMObject type", Gfx::TextAlignment::CenterLeft, [](auto& object) { - auto type = object.get("vmobject").to_string(); - if (type.ends_with("VMObject")) + auto type = object.get("vmobject"sv).to_string(); + if (type.ends_with("VMObject"sv)) type = type.substring(0, type.length() - 8); return type; }); pid_vm_fields.empend("Purgeable", Gfx::TextAlignment::CenterLeft, [](auto& object) { - if (object.get("volatile").to_bool()) + if (object.get("volatile"sv).to_bool()) return "Volatile"; return "Non-volatile"; }); @@ -98,7 +98,7 @@ ProcessMemoryMapWidget::ProcessMemoryMapWidget() return GUI::Variant(0); }, [](JsonObject const& object) { - auto pagemap = object.get("pagemap").as_string_or({}); + auto pagemap = object.get("pagemap"sv).as_string_or({}); return pagemap; }); pid_vm_fields.empend("cow_pages", "# CoW", Gfx::TextAlignment::CenterRight); diff --git a/Userland/Applications/SystemMonitor/ProcessModel.cpp b/Userland/Applications/SystemMonitor/ProcessModel.cpp index 03322e6d24e..092cbbdca40 100644 --- a/Userland/Applications/SystemMonitor/ProcessModel.cpp +++ b/Userland/Applications/SystemMonitor/ProcessModel.cpp @@ -38,7 +38,7 @@ ProcessModel::ProcessModel() auto cpuinfo_array = json.value().as_array(); cpuinfo_array.for_each([&](auto& value) { auto& cpu_object = value.as_object(); - auto cpu_id = cpu_object.get("processor").as_u32(); + auto cpu_id = cpu_object.get("processor"sv).as_u32(); m_cpus.append(make(cpu_id)); }); } @@ -46,7 +46,7 @@ ProcessModel::ProcessModel() if (m_cpus.is_empty()) m_cpus.append(make(0)); - m_kernel_process_icon = GUI::Icon::default_icon("gear"); + m_kernel_process_icon = GUI::Icon::default_icon("gear"sv); } int ProcessModel::row_count(GUI::ModelIndex const& index) const diff --git a/Userland/Applications/SystemMonitor/main.cpp b/Userland/Applications/SystemMonitor/main.cpp index 98065b3599a..4a940b04520 100644 --- a/Userland/Applications/SystemMonitor/main.cpp +++ b/Userland/Applications/SystemMonitor/main.cpp @@ -138,7 +138,7 @@ public: processors_field.empend("brand", "Brand", Gfx::TextAlignment::CenterLeft); processors_field.empend("Features", Gfx::TextAlignment::CenterLeft, [](auto& object) { StringBuilder builder; - auto features = object.get("features").as_array(); + auto features = object.get("features"sv).as_array(); for (auto& feature : features.values()) { builder.append(feature.to_string()); builder.append(' '); @@ -163,38 +163,38 @@ public: pci_fields.empend( "Address", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) { - auto seg = object.get("seg").to_u32(); - auto bus = object.get("bus").to_u32(); - auto device = object.get("device").to_u32(); - auto function = object.get("function").to_u32(); + auto seg = object.get("seg"sv).to_u32(); + auto bus = object.get("bus"sv).to_u32(); + auto device = object.get("device"sv).to_u32(); + auto function = object.get("function"sv).to_u32(); return String::formatted("{:04x}:{:02x}:{:02x}.{}", seg, bus, device, function); }); pci_fields.empend( "Class", Gfx::TextAlignment::CenterLeft, [this](const JsonObject& object) { - auto class_id = object.get("class").to_u32(); - String class_name = m_db ? m_db->get_class(class_id) : nullptr; + auto class_id = object.get("class"sv).to_u32(); + String class_name = m_db ? m_db->get_class(class_id) : StringView {}; return class_name.is_empty() ? String::formatted("Unknown class: {:04x}", class_id) : class_name; }); pci_fields.empend( "Vendor", Gfx::TextAlignment::CenterLeft, [this](const JsonObject& object) { - auto vendor_id = object.get("vendor_id").to_u32(); - String vendor_name = m_db ? m_db->get_vendor(vendor_id) : nullptr; + auto vendor_id = object.get("vendor_id"sv).to_u32(); + String vendor_name = m_db ? m_db->get_vendor(vendor_id) : StringView {}; return vendor_name.is_empty() ? String::formatted("Unknown vendor: {:02x}", vendor_id) : vendor_name; }); pci_fields.empend( "Device", Gfx::TextAlignment::CenterLeft, [this](const JsonObject& object) { - auto vendor_id = object.get("vendor_id").to_u32(); - auto device_id = object.get("device_id").to_u32(); - String device_name = m_db ? m_db->get_device(vendor_id, device_id) : nullptr; + auto vendor_id = object.get("vendor_id"sv).to_u32(); + auto device_id = object.get("device_id"sv).to_u32(); + String device_name = m_db ? m_db->get_device(vendor_id, device_id) : StringView {}; return device_name.is_empty() ? String::formatted("Unknown device: {:02x}", device_id) : device_name; }); pci_fields.empend( "Revision", Gfx::TextAlignment::CenterRight, [](const JsonObject& object) { - auto revision_id = object.get("revision_id").to_u32(); + auto revision_id = object.get("revision_id"sv).to_u32(); return String::formatted("{:02x}", revision_id); }); @@ -227,18 +227,18 @@ public: [](const JsonObject& object) { StringBuilder size_builder; size_builder.append(" "); - size_builder.append(human_readable_size(object.get("total_block_count").to_u64() * object.get("block_size").to_u64())); + size_builder.append(human_readable_size(object.get("total_block_count"sv).to_u64() * object.get("block_size"sv).to_u64())); size_builder.append(" "); return size_builder.to_string(); }, [](const JsonObject& object) { - return object.get("total_block_count").to_u64() * object.get("block_size").to_u64(); + return object.get("total_block_count"sv).to_u64() * object.get("block_size"sv).to_u64(); }, [](const JsonObject& object) { - auto total_blocks = object.get("total_block_count").to_u64(); + auto total_blocks = object.get("total_block_count"sv).to_u64(); if (total_blocks == 0) return 0; - auto free_blocks = object.get("free_block_count").to_u64(); + auto free_blocks = object.get("free_block_count"sv).to_u64(); auto used_blocks = total_blocks - free_blocks; int percentage = (static_cast(used_blocks) / static_cast(total_blocks) * 100.0); return percentage; @@ -246,34 +246,34 @@ public: df_fields.empend( "Used", Gfx::TextAlignment::CenterRight, [](const JsonObject& object) { - auto total_blocks = object.get("total_block_count").to_u64(); - auto free_blocks = object.get("free_block_count").to_u64(); + auto total_blocks = object.get("total_block_count"sv).to_u64(); + auto free_blocks = object.get("free_block_count"sv).to_u64(); auto used_blocks = total_blocks - free_blocks; - return human_readable_size(used_blocks * object.get("block_size").to_u64()); }, + return human_readable_size(used_blocks * object.get("block_size"sv).to_u64()); }, [](const JsonObject& object) { - auto total_blocks = object.get("total_block_count").to_u64(); - auto free_blocks = object.get("free_block_count").to_u64(); + auto total_blocks = object.get("total_block_count"sv).to_u64(); + auto free_blocks = object.get("free_block_count"sv).to_u64(); auto used_blocks = total_blocks - free_blocks; - return used_blocks * object.get("block_size").to_u64(); + return used_blocks * object.get("block_size"sv).to_u64(); }); df_fields.empend( "Available", Gfx::TextAlignment::CenterRight, [](const JsonObject& object) { - return human_readable_size(object.get("free_block_count").to_u64() * object.get("block_size").to_u64()); + return human_readable_size(object.get("free_block_count"sv).to_u64() * object.get("block_size"sv).to_u64()); }, [](const JsonObject& object) { - return object.get("free_block_count").to_u64() * object.get("block_size").to_u64(); + return object.get("free_block_count"sv).to_u64() * object.get("block_size"sv).to_u64(); }); df_fields.empend("Access", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) { - bool readonly = object.get("readonly").to_bool(); - int mount_flags = object.get("mount_flags").to_int(); + bool readonly = object.get("readonly"sv).to_bool(); + int mount_flags = object.get("mount_flags"sv).to_int(); return readonly || (mount_flags & MS_RDONLY) ? "Read-only" : "Read/Write"; }); df_fields.empend("Mount flags", Gfx::TextAlignment::CenterLeft, [](const JsonObject& object) { - int mount_flags = object.get("mount_flags").to_int(); + int mount_flags = object.get("mount_flags"sv).to_int(); StringBuilder builder; bool first = true; - auto check = [&](int flag, const char* name) { + auto check = [&](int flag, StringView name) { if (!(mount_flags & flag)) return; if (!first) @@ -281,13 +281,13 @@ public: builder.append(name); first = false; }; - check(MS_NODEV, "nodev"); - check(MS_NOEXEC, "noexec"); - check(MS_NOSUID, "nosuid"); - check(MS_BIND, "bind"); - check(MS_RDONLY, "ro"); - check(MS_WXALLOWED, "wxallowed"); - check(MS_AXALLOWED, "axallowed"); + check(MS_NODEV, "nodev"sv); + check(MS_NOEXEC, "noexec"sv); + check(MS_NOSUID, "nosuid"sv); + check(MS_BIND, "bind"sv); + check(MS_RDONLY, "ro"sv); + check(MS_WXALLOWED, "wxallowed"sv); + check(MS_AXALLOWED, "axallowed"sv); if (builder.string_view().is_empty()) return String("defaults"); return builder.to_string(); @@ -365,7 +365,7 @@ ErrorOr serenity_main(Main::Arguments arguments) parser.parse(arguments); StringView args_tab_view = args_tab; - auto app_icon = GUI::Icon::default_icon("app-system-monitor"); + auto app_icon = GUI::Icon::default_icon("app-system-monitor"sv); auto window = GUI::Window::construct(); window->set_title("System Monitor"); @@ -402,10 +402,10 @@ ErrorOr serenity_main(Main::Arguments arguments) process_table_view.set_key_column_and_sort_order(ProcessModel::Column::CPU, GUI::SortOrder::Descending); process_model->update(); - i32 frequency = Config::read_i32("SystemMonitor", "Monitor", "Frequency", 3); + i32 frequency = Config::read_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, 3); if (frequency != 1 && frequency != 3 && frequency != 5) { frequency = 3; - Config::write_i32("SystemMonitor", "Monitor", "Frequency", frequency); + Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, frequency); } auto& refresh_timer = window->add( @@ -439,29 +439,29 @@ ErrorOr serenity_main(Main::Arguments arguments) }; auto kill_action = GUI::Action::create( - "&Kill Process", { Mod_Ctrl, Key_K }, { Key_Delete }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/kill.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + "&Kill Process", { Mod_Ctrl, Key_K }, { Key_Delete }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/kill.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to kill \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGKILL); }, &process_table_view); auto stop_action = GUI::Action::create( - "&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop-hand.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + "&Stop Process", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/stop-hand.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; - auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto rc = GUI::MessageBox::show(window, String::formatted("Do you really want to stop \"{}\" (PID {})?", selected_name(ProcessModel::Column::Name), pid), "System Monitor"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (rc == GUI::Dialog::ExecResult::Yes) kill(pid, SIGSTOP); }, &process_table_view); auto continue_action = GUI::Action::create( - "&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/continue.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + "&Continue Process", { Mod_Ctrl, Key_C }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/continue.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid != -1) kill(pid, SIGCONT); @@ -470,12 +470,12 @@ ErrorOr serenity_main(Main::Arguments arguments) auto profile_action = GUI::Action::create( "&Profile Process", { Mod_Ctrl, Key_P }, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { pid_t pid = selected_id(ProcessModel::Column::PID); if (pid == -1) return; auto pid_string = String::number(pid); - GUI::Process::spawn_or_show_error(window, "/bin/Profiler", Array { "--pid", pid_string.characters() }); + GUI::Process::spawn_or_show_error(window, "/bin/Profiler"sv, Array { "--pid", pid_string.characters() }); }, &process_table_view); @@ -531,7 +531,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto make_frequency_action = [&](int seconds) { auto action = GUI::Action::create_checkable(String::formatted("&{} Sec", seconds), [&refresh_timer, seconds](auto&) { - Config::write_i32("SystemMonitor", "Monitor", "Frequency", seconds); + Config::write_i32("SystemMonitor"sv, "Monitor"sv, "Frequency"sv, seconds); refresh_timer.restart(seconds * 1000); }); action->set_status_tip(String::formatted("Refresh every {} seconds", seconds)); @@ -597,7 +597,7 @@ ErrorOr> build_process_window(pid_t pid) window->resize(480, 360); window->set_title(String::formatted("PID {} - System Monitor", pid)); - auto app_icon = GUI::Icon::default_icon("app-system-monitor"); + auto app_icon = GUI::Icon::default_icon("app-system-monitor"sv); window->set_icon(app_icon.bitmap_for_size(16)); auto main_widget = TRY(window->try_set_main_widget()); diff --git a/Userland/Applications/Terminal/main.cpp b/Userland/Applications/Terminal/main.cpp index bc942f7a97a..c0e0cedbc0b 100644 --- a/Userland/Applications/Terminal/main.cpp +++ b/Userland/Applications/Terminal/main.cpp @@ -157,11 +157,11 @@ static ErrorOr run_command(String command, bool keep_open) arguments.append(shell); if (!command.is_empty()) { if (keep_open) - arguments.append("--keep-open"); - arguments.append("-c"); + arguments.append("--keep-open"sv); + arguments.append("-c"sv); arguments.append(command); } - auto env = TRY(FixedArray::try_create({ "TERM=xterm", "PAGER=more", "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin" })); + auto env = TRY(FixedArray::try_create({ "TERM=xterm"sv, "PAGER=more"sv, "PATH=/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv })); TRY(Core::System::exec(shell, arguments, Core::System::SearchInPath::No, env.span())); VERIFY_NOT_REACHED(); } @@ -189,13 +189,13 @@ static ErrorOr> create_find_window(VT::TerminalWidget find_textbox->set_fixed_width(230); find_textbox->set_focus(true); if (terminal.has_selection()) - find_textbox->set_text(terminal.selected_text().replace("\n", " ", ReplaceMode::All)); + find_textbox->set_text(terminal.selected_text().replace("\n"sv, " "sv, ReplaceMode::All)); auto find_backwards = TRY(find->try_add()); find_backwards->set_fixed_width(25); - find_backwards->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors()); + find_backwards->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"sv).release_value_but_fixme_should_propagate_errors()); auto find_forwards = TRY(find->try_add()); find_forwards->set_fixed_width(25); - find_forwards->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors()); + find_forwards->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"sv).release_value_but_fixme_should_propagate_errors()); find_textbox->on_return_pressed = [find_backwards]() mutable { find_backwards->click(); @@ -280,14 +280,14 @@ ErrorOr serenity_main(Main::Arguments arguments) if (command_to_execute) TRY(run_command(command_to_execute, keep_open)); else - TRY(run_command(Config::read_string("Terminal", "Startup", "Command", ""), false)); + TRY(run_command(Config::read_string("Terminal"sv, "Startup"sv, "Command"sv, ""sv), false)); VERIFY_NOT_REACHED(); } auto ptsname = TRY(Core::System::ptsname(ptm_fd)); utmp_update(ptsname, shell_pid, true); - auto app_icon = GUI::Icon::default_icon("app-terminal"); + auto app_icon = GUI::Icon::default_icon("app-terminal"sv); auto window = TRY(GUI::Window::try_create()); window->set_title("Terminal"); @@ -308,10 +308,10 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_icon(app_icon.bitmap_for_size(16)); Config::monitor_domain("Terminal"); - auto should_confirm_close = Config::read_bool("Terminal", "Terminal", "ConfirmClose", true); + auto should_confirm_close = Config::read_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, true); TerminalChangeListener listener { terminal }; - auto bell = Config::read_string("Terminal", "Window", "Bell", "Visible"); + auto bell = Config::read_string("Terminal"sv, "Window"sv, "Bell"sv, "Visible"sv); if (bell == "AudibleBeep") { terminal->set_bell_mode(VT::TerminalWidget::BellMode::AudibleBeep); } else if (bell == "Disabled") { @@ -320,35 +320,35 @@ ErrorOr serenity_main(Main::Arguments arguments) terminal->set_bell_mode(VT::TerminalWidget::BellMode::Visible); } - auto cursor_shape = VT::TerminalWidget::parse_cursor_shape(Config::read_string("Terminal", "Cursor", "Shape", "Block")).value_or(VT::CursorShape::Block); + auto cursor_shape = VT::TerminalWidget::parse_cursor_shape(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv, "Block"sv)).value_or(VT::CursorShape::Block); terminal->set_cursor_shape(cursor_shape); - auto cursor_blinking = Config::read_bool("Terminal", "Cursor", "Blinking", true); + auto cursor_blinking = Config::read_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, true); terminal->set_cursor_blinking(cursor_blinking); auto find_window = TRY(create_find_window(terminal)); - auto new_opacity = Config::read_i32("Terminal", "Window", "Opacity", 255); + auto new_opacity = Config::read_i32("Terminal"sv, "Window"sv, "Opacity"sv, 255); terminal->set_opacity(new_opacity); window->set_has_alpha_channel(new_opacity < 255); - auto new_scrollback_size = Config::read_i32("Terminal", "Terminal", "MaxHistorySize", terminal->max_history_size()); + auto new_scrollback_size = Config::read_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, terminal->max_history_size()); terminal->set_max_history_size(new_scrollback_size); - auto show_scroll_bar = Config::read_bool("Terminal", "Terminal", "ShowScrollBar", true); + auto show_scroll_bar = Config::read_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, true); terminal->set_show_scrollbar(show_scroll_bar); - auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value_but_fixme_should_propagate_errors(), + auto open_settings_action = GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { - GUI::Process::spawn_or_show_error(window, "/bin/TerminalSettings"); + GUI::Process::spawn_or_show_error(window, "/bin/TerminalSettings"sv); }); TRY(terminal->context_menu().try_add_separator()); TRY(terminal->context_menu().try_add_action(open_settings_action)); auto file_menu = TRY(window->try_add_menu("&File")); - TRY(file_menu->try_add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { - GUI::Process::spawn_or_show_error(window, "/bin/Terminal"); + TRY(file_menu->try_add_action(GUI::Action::create("Open New &Terminal", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { + GUI::Process::spawn_or_show_error(window, "/bin/Terminal"sv); }))); TRY(file_menu->try_add_action(open_settings_action)); @@ -383,7 +383,7 @@ ErrorOr serenity_main(Main::Arguments arguments) close_message = "There is a background process running in this terminal. Closing the terminal may kill it."; } if (close_message.has_value()) - return GUI::MessageBox::show(window, *close_message, "Close this terminal?", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); + return GUI::MessageBox::show(window, *close_message, "Close this terminal?"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); return GUI::MessageBox::ExecResult::OK; }; @@ -397,7 +397,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(edit_menu->try_add_action(terminal->copy_action())); TRY(edit_menu->try_add_action(terminal->paste_action())); TRY(edit_menu->try_add_separator()); - TRY(edit_menu->try_add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), + TRY(edit_menu->try_add_action(GUI::Action::create("&Find...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { find_window->show(); find_window->move_to_front(); diff --git a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp index a2d6f388d8a..ca3c9ab51ff 100644 --- a/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp +++ b/Userland/Applications/TerminalSettings/TerminalSettingsWidget.cpp @@ -38,7 +38,7 @@ TerminalSettingsMainWidget::TerminalSettingsMainWidget() auto& visual_bell_radio = *find_descendant_of_type_named("visual_bell_radio"); auto& no_bell_radio = *find_descendant_of_type_named("no_bell_radio"); - m_bell_mode = parse_bell(Config::read_string("Terminal", "Window", "Bell")); + m_bell_mode = parse_bell(Config::read_string("Terminal"sv, "Window"sv, "Bell"sv)); m_original_bell_mode = m_bell_mode; switch (m_bell_mode) { @@ -55,46 +55,46 @@ TerminalSettingsMainWidget::TerminalSettingsMainWidget() beep_bell_radio.on_checked = [this](bool) { m_bell_mode = VT::TerminalWidget::BellMode::AudibleBeep; - Config::write_string("Terminal", "Window", "Bell", stringify_bell(m_bell_mode)); + Config::write_string("Terminal"sv, "Window"sv, "Bell"sv, stringify_bell(m_bell_mode)); set_modified(true); }; visual_bell_radio.on_checked = [this](bool) { m_bell_mode = VT::TerminalWidget::BellMode::Visible; - Config::write_string("Terminal", "Window", "Bell", stringify_bell(m_bell_mode)); + Config::write_string("Terminal"sv, "Window"sv, "Bell"sv, stringify_bell(m_bell_mode)); set_modified(true); }; no_bell_radio.on_checked = [this](bool) { m_bell_mode = VT::TerminalWidget::BellMode::Disabled; - Config::write_string("Terminal", "Window", "Bell", stringify_bell(m_bell_mode)); + Config::write_string("Terminal"sv, "Window"sv, "Bell"sv, stringify_bell(m_bell_mode)); set_modified(true); }; - m_max_history_size = Config::read_i32("Terminal", "Terminal", "MaxHistorySize"); + m_max_history_size = Config::read_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv); m_original_max_history_size = m_max_history_size; auto& history_size_spinbox = *find_descendant_of_type_named("history_size_spinbox"); history_size_spinbox.set_value(m_max_history_size, GUI::AllowCallback::No); history_size_spinbox.on_change = [this](int value) { m_max_history_size = value; - Config::write_i32("Terminal", "Terminal", "MaxHistorySize", static_cast(m_max_history_size)); + Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_max_history_size)); set_modified(true); }; - m_show_scrollbar = Config::read_bool("Terminal", "Terminal", "ShowScrollBar", true); + m_show_scrollbar = Config::read_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, true); m_orignal_show_scrollbar = m_show_scrollbar; auto& show_scrollbar_checkbox = *find_descendant_of_type_named("terminal_show_scrollbar"); show_scrollbar_checkbox.on_checked = [&](bool show_scrollbar) { m_show_scrollbar = show_scrollbar; - Config::write_bool("Terminal", "Terminal", "ShowScrollBar", show_scrollbar); + Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, show_scrollbar); set_modified(true); }; show_scrollbar_checkbox.set_checked(m_show_scrollbar, GUI::AllowCallback::No); - m_confirm_close = Config::read_bool("Terminal", "Terminal", "ConfirmClose", true); + m_confirm_close = Config::read_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, true); m_orignal_confirm_close = m_confirm_close; auto& confirm_close_checkbox = *find_descendant_of_type_named("terminal_confirm_close"); confirm_close_checkbox.on_checked = [&](bool confirm_close) { m_confirm_close = confirm_close; - Config::write_bool("Terminal", "Terminal", "ConfirmClose", confirm_close); + Config::write_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, confirm_close); set_modified(true); }; confirm_close_checkbox.set_checked(m_confirm_close, GUI::AllowCallback::No); @@ -105,16 +105,16 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() load_from_gml(terminal_settings_view_gml); auto& slider = *find_descendant_of_type_named("background_opacity_slider"); - m_opacity = Config::read_i32("Terminal", "Window", "Opacity"); + m_opacity = Config::read_i32("Terminal"sv, "Window"sv, "Opacity"sv); m_original_opacity = m_opacity; slider.set_value(m_opacity); slider.on_change = [this](int value) { m_opacity = value; - Config::write_i32("Terminal", "Window", "Opacity", static_cast(m_opacity)); + Config::write_i32("Terminal"sv, "Window"sv, "Opacity"sv, static_cast(m_opacity)); set_modified(true); }; - m_color_scheme = Config::read_string("Terminal", "Window", "ColorScheme"); + m_color_scheme = Config::read_string("Terminal"sv, "Window"sv, "ColorScheme"sv); m_original_color_scheme = m_color_scheme; // The settings window takes a reference to this vector, so it needs to outlive this scope. // As long as we ensure that only one settings window may be open at a time (which we do), @@ -124,7 +124,7 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() Core::DirIterator iterator("/res/terminal-colors", Core::DirIterator::SkipParentAndBaseDir); while (iterator.has_next()) { auto path = iterator.next_path(); - color_scheme_names.append(path.replace(".ini", "", ReplaceMode::FirstOnly)); + color_scheme_names.append(path.replace(".ini"sv, ""sv, ReplaceMode::FirstOnly)); } quick_sort(color_scheme_names); auto& color_scheme_combo = *find_descendant_of_type_named("color_scheme_combo"); @@ -134,13 +134,13 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() color_scheme_combo.set_enabled(color_scheme_names.size() > 1); color_scheme_combo.on_change = [&](auto&, const GUI::ModelIndex& index) { m_color_scheme = index.data().as_string(); - Config::write_string("Terminal", "Window", "ColorScheme", m_color_scheme); + Config::write_string("Terminal"sv, "Window"sv, "ColorScheme"sv, m_color_scheme); set_modified(true); }; auto& font_button = *find_descendant_of_type_named("terminal_font_button"); auto& font_text = *find_descendant_of_type_named("terminal_font_label"); - auto font_name = Config::read_string("Terminal", "Text", "Font"); + auto font_name = Config::read_string("Terminal"sv, "Text"sv, "Font"sv); if (font_name.is_empty()) m_font = Gfx::FontDatabase::the().default_fixed_width_font(); else @@ -154,7 +154,7 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() m_font = picker->font(); font_text.set_text(m_font->human_readable_name()); font_text.set_font(m_font); - Config::write_string("Terminal", "Text", "Font", m_font->qualified_name()); + Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_font->qualified_name()); set_modified(true); } }; @@ -167,13 +167,13 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() m_font = Gfx::FontDatabase::the().default_fixed_width_font(); font_text.set_text(m_font->human_readable_name()); font_text.set_font(m_font); - Config::write_string("Terminal", "Text", "Font", m_font->qualified_name()); + Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_font->qualified_name()); } else { font_selection.set_enabled(true); m_font = font_name.is_empty() ? Gfx::FontDatabase::the().default_fixed_width_font() : Gfx::FontDatabase::the().get_by_name(font_name); - Config::write_string("Terminal", "Text", "Font", m_font->qualified_name()); + Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_font->qualified_name()); } set_modified(true); }; @@ -188,10 +188,10 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() auto& terminal_cursor_blinking = *find_descendant_of_type_named("terminal_cursor_blinking"); - m_cursor_shape = VT::TerminalWidget::parse_cursor_shape(Config::read_string("Terminal", "Cursor", "Shape")).value_or(VT::CursorShape::Block); + m_cursor_shape = VT::TerminalWidget::parse_cursor_shape(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv)).value_or(VT::CursorShape::Block); m_original_cursor_shape = m_cursor_shape; - m_cursor_is_blinking_set = Config::read_bool("Terminal", "Cursor", "Blinking", true); + m_cursor_is_blinking_set = Config::read_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, true); m_original_cursor_is_blinking_set = m_cursor_is_blinking_set; switch (m_cursor_shape) { @@ -208,30 +208,30 @@ TerminalSettingsViewWidget::TerminalSettingsViewWidget() terminal_cursor_blinking.on_checked = [&](bool is_checked) { set_modified(true); m_cursor_is_blinking_set = is_checked; - Config::write_bool("Terminal", "Cursor", "Blinking", is_checked); + Config::write_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, is_checked); }; - terminal_cursor_blinking.set_checked(Config::read_bool("Terminal", "Cursor", "Blinking", true)); + terminal_cursor_blinking.set_checked(Config::read_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, true)); terminal_cursor_block.on_checked = [&](bool) { set_modified(true); m_cursor_shape = VT::CursorShape::Block; - Config::write_string("Terminal", "Cursor", "Shape", "Block"); + Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, "Block"sv); }; - terminal_cursor_block.set_checked(Config::read_string("Terminal", "Cursor", "Shape") == "Block"); + terminal_cursor_block.set_checked(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv) == "Block"sv); terminal_cursor_underline.on_checked = [&](bool) { set_modified(true); m_cursor_shape = VT::CursorShape::Underline; - Config::write_string("Terminal", "Cursor", "Shape", "Underline"); + Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, "Underline"sv); }; - terminal_cursor_underline.set_checked(Config::read_string("Terminal", "Cursor", "Shape") == "Underline"); + terminal_cursor_underline.set_checked(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv) == "Underline"sv); terminal_cursor_bar.on_checked = [&](bool) { set_modified(true); m_cursor_shape = VT::CursorShape::Bar; - Config::write_string("Terminal", "Cursor", "Shape", "Bar"); + Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, "Bar"sv); }; - terminal_cursor_bar.set_checked(Config::read_string("Terminal", "Cursor", "Shape") == "Bar"); + terminal_cursor_bar.set_checked(Config::read_string("Terminal"sv, "Cursor"sv, "Shape"sv) == "Bar"sv); } VT::TerminalWidget::BellMode TerminalSettingsMainWidget::parse_bell(StringView bell_string) @@ -266,10 +266,10 @@ void TerminalSettingsMainWidget::apply_settings() } void TerminalSettingsMainWidget::write_back_settings() const { - Config::write_i32("Terminal", "Terminal", "MaxHistorySize", static_cast(m_original_max_history_size)); - Config::write_bool("Terminal", "Terminal", "ShowScrollBar", m_orignal_show_scrollbar); - Config::write_bool("Terminal", "Terminal", "ConfirmClose", m_orignal_confirm_close); - Config::write_string("Terminal", "Window", "Bell", stringify_bell(m_original_bell_mode)); + Config::write_i32("Terminal"sv, "Terminal"sv, "MaxHistorySize"sv, static_cast(m_original_max_history_size)); + Config::write_bool("Terminal"sv, "Terminal"sv, "ShowScrollBar"sv, m_orignal_show_scrollbar); + Config::write_bool("Terminal"sv, "Terminal"sv, "ConfirmClose"sv, m_orignal_confirm_close); + Config::write_string("Terminal"sv, "Window"sv, "Bell"sv, stringify_bell(m_original_bell_mode)); } void TerminalSettingsMainWidget::cancel_settings() @@ -289,11 +289,11 @@ void TerminalSettingsViewWidget::apply_settings() void TerminalSettingsViewWidget::write_back_settings() const { - Config::write_i32("Terminal", "Window", "Opacity", static_cast(m_original_opacity)); - Config::write_string("Terminal", "Text", "Font", m_original_font->qualified_name()); - Config::write_string("Terminal", "Window", "ColorScheme", m_original_color_scheme); - Config::write_string("Terminal", "Cursor", "Shape", VT::TerminalWidget::stringify_cursor_shape(m_original_cursor_shape)); - Config::write_bool("Terminal", "Cursor", "Blinking", m_original_cursor_is_blinking_set); + Config::write_i32("Terminal"sv, "Window"sv, "Opacity"sv, static_cast(m_original_opacity)); + Config::write_string("Terminal"sv, "Text"sv, "Font"sv, m_original_font->qualified_name()); + Config::write_string("Terminal"sv, "Window"sv, "ColorScheme"sv, m_original_color_scheme); + Config::write_string("Terminal"sv, "Cursor"sv, "Shape"sv, VT::TerminalWidget::stringify_cursor_shape(m_original_cursor_shape)); + Config::write_bool("Terminal"sv, "Cursor"sv, "Blinking"sv, m_original_cursor_is_blinking_set); } void TerminalSettingsViewWidget::cancel_settings() diff --git a/Userland/Applications/TerminalSettings/main.cpp b/Userland/Applications/TerminalSettings/main.cpp index bfa191df20d..1deafcc8a27 100644 --- a/Userland/Applications/TerminalSettings/main.cpp +++ b/Userland/Applications/TerminalSettings/main.cpp @@ -30,12 +30,12 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-terminal"); + auto app_icon = GUI::Icon::default_icon("app-terminal"sv); auto window = TRY(GUI::SettingsWindow::create("Terminal Settings")); window->set_icon(app_icon.bitmap_for_size(16)); - (void)TRY(window->add_tab("Terminal", "terminal")); - (void)TRY(window->add_tab("View", "view")); + (void)TRY(window->add_tab("Terminal"sv, "terminal"sv)); + (void)TRY(window->add_tab("View"sv, "view"sv)); window->set_active_tab(selected_tab); window->show(); diff --git a/Userland/Applications/TextEditor/MainWidget.cpp b/Userland/Applications/TextEditor/MainWidget.cpp index 383d0e2d47a..13d1eaf2e64 100644 --- a/Userland/Applications/TextEditor/MainWidget.cpp +++ b/Userland/Applications/TextEditor/MainWidget.cpp @@ -76,10 +76,10 @@ MainWidget::MainWidget() m_replace_widget = *find_descendant_of_type_named("replace_widget"); m_find_textbox = *find_descendant_of_type_named("find_textbox"); - m_find_textbox->set_placeholder("Find"); + m_find_textbox->set_placeholder("Find"sv); m_replace_textbox = *find_descendant_of_type_named("replace_textbox"); - m_replace_textbox->set_placeholder("Replace"); + m_replace_textbox->set_placeholder("Replace"sv); m_match_case_checkbox = *find_descendant_of_type_named("match_case_checkbox"); m_match_case_checkbox->on_checked = [this](auto is_checked) { @@ -99,11 +99,11 @@ MainWidget::MainWidget() }; m_wrap_around_checkbox->set_checked(true); - m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_find_next_action = GUI::Action::create("Find &Next", { Mod_Ctrl, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { find_text(GUI::TextEditor::SearchDirection::Forward, ShowMessageIfNoResutls::Yes); }); - m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_find_previous_action = GUI::Action::create("Find Pr&evious", { Mod_Ctrl | Mod_Shift, Key_G }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { find_text(GUI::TextEditor::SearchDirection::Backward, ShowMessageIfNoResutls::Yes); }); @@ -122,7 +122,7 @@ MainWidget::MainWidget() } else { GUI::MessageBox::show(window(), String::formatted("Not found: \"{}\"", needle), - "Not found", + "Not found"sv, GUI::MessageBox::Type::Information); } }); @@ -147,11 +147,11 @@ MainWidget::MainWidget() m_find_previous_button = *find_descendant_of_type_named("find_previous_button"); m_find_previous_button->set_action(*m_find_previous_action); - m_find_previous_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png").release_value_but_fixme_should_propagate_errors()); + m_find_previous_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-previous.png"sv).release_value_but_fixme_should_propagate_errors()); m_find_next_button = *find_descendant_of_type_named("find_next_button"); m_find_next_button->set_action(*m_find_next_action); - m_find_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png").release_value_but_fixme_should_propagate_errors()); + m_find_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find-next.png"sv).release_value_but_fixme_should_propagate_errors()); m_find_textbox->on_return_pressed = [this] { m_find_next_button->click(); @@ -191,7 +191,7 @@ MainWidget::MainWidget() }); m_vim_emulation_setting_action->set_checked(false); - m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_find_replace_action = GUI::Action::create("&Find/Replace...", { Mod_Ctrl, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { m_find_replace_widget->set_visible(true); m_find_widget->set_visible(true); m_replace_widget->set_visible(true); @@ -216,7 +216,7 @@ MainWidget::MainWidget() m_statusbar->segment(1).set_clickable(true); m_statusbar->segment(1).set_menu(m_syntax_statusbar_menu); m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed); - auto width = font().width("Ln 0000, Col 000") + font().max_glyph_width(); + auto width = font().width("Ln 0000, Col 000"sv) + font().max_glyph_width(); m_statusbar->segment(2).set_fixed_width(width); m_statusbar->segment(2).set_clickable(true); m_statusbar->segment(2).set_menu(m_line_column_statusbar_menu); @@ -236,7 +236,7 @@ MainWidget::MainWidget() m_editor->on_selection_change = [this] { update_statusbar(); }; m_editor->on_highlighter_change = [this] { update_statusbar(); }; - m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) { + m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](GUI::Action const&) { if (editor().document().is_modified()) { auto save_document_first_result = GUI::MessageBox::ask_about_unsaved_changes(window(), m_path, editor().document().undo_stack().last_unmodified_timestamp()); if (save_document_first_result == GUI::Dialog::ExecResult::Yes) @@ -273,7 +273,7 @@ MainWidget::MainWidget() auto file = response.release_value(); if (!m_editor->write_to_file(*file)) { - GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -291,7 +291,7 @@ MainWidget::MainWidget() return; if (!m_editor->write_to_file(*response.value())) { - GUI::MessageBox::show(window(), "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); } }); @@ -327,7 +327,7 @@ WebView::OutOfProcessWebView& MainWidget::ensure_web_view() GUI::MessageBox::show( window(), String::formatted("The link to '{}' could not be opened.", url), - "Failed to open link", + "Failed to open link"sv, GUI::MessageBox::Type::Error); } }; @@ -389,26 +389,26 @@ void MainWidget::initialize_menubar(GUI::Window& window) m_layout_toolbar_action = GUI::Action::create_checkable("&Toolbar", [&](auto& action) { action.is_checked() ? m_toolbar_container->set_visible(true) : m_toolbar_container->set_visible(false); - Config::write_bool("TextEditor", "Layout", "ShowToolbar", action.is_checked()); + Config::write_bool("TextEditor"sv, "Layout"sv, "ShowToolbar"sv, action.is_checked()); }); - auto show_toolbar = Config::read_bool("TextEditor", "Layout", "ShowToolbar", true); + auto show_toolbar = Config::read_bool("TextEditor"sv, "Layout"sv, "ShowToolbar"sv, true); m_layout_toolbar_action->set_checked(show_toolbar); m_toolbar_container->set_visible(show_toolbar); m_layout_statusbar_action = GUI::Action::create_checkable("&Status Bar", [&](auto& action) { action.is_checked() ? m_statusbar->set_visible(true) : m_statusbar->set_visible(false); - Config::write_bool("TextEditor", "Layout", "ShowStatusbar", action.is_checked()); + Config::write_bool("TextEditor"sv, "Layout"sv, "ShowStatusbar"sv, action.is_checked()); update_statusbar(); }); - auto show_statusbar = Config::read_bool("TextEditor", "Layout", "ShowStatusbar", true); + auto show_statusbar = Config::read_bool("TextEditor"sv, "Layout"sv, "ShowStatusbar"sv, true); m_layout_statusbar_action->set_checked(show_statusbar); m_statusbar->set_visible(show_statusbar); m_layout_ruler_action = GUI::Action::create_checkable("&Ruler", [&](auto& action) { action.is_checked() ? m_editor->set_ruler_visible(true) : m_editor->set_ruler_visible(false); - Config::write_bool("TextEditor", "Layout", "ShowRuler", action.is_checked()); + Config::write_bool("TextEditor"sv, "Layout"sv, "ShowRuler"sv, action.is_checked()); }); - auto show_ruler = Config::read_bool("TextEditor", "Layout", "ShowRuler", true); + auto show_ruler = Config::read_bool("TextEditor"sv, "Layout"sv, "ShowRuler"sv, true); m_layout_ruler_action->set_checked(show_ruler); m_editor->set_ruler_visible(show_ruler); @@ -420,7 +420,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) view_menu.add_separator(); - view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), + view_menu.add_action(GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto picker = GUI::FontPicker::construct(&window, &m_editor->font(), false); if (picker->exec() == GUI::Dialog::ExecResult::OK) { @@ -435,15 +435,15 @@ void MainWidget::initialize_menubar(GUI::Window& window) auto& wrapping_mode_menu = view_menu.add_submenu("&Wrapping Mode"); m_no_wrapping_action = GUI::Action::create_checkable("&No Wrapping", [&](auto&) { m_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); - Config::write_string("TextEditor", "View", "WrappingMode", "None"); + Config::write_string("TextEditor"sv, "View"sv, "WrappingMode"sv, "None"sv); }); m_wrap_anywhere_action = GUI::Action::create_checkable("Wrap &Anywhere", [&](auto&) { m_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAnywhere); - Config::write_string("TextEditor", "View", "WrappingMode", "Anywhere"); + Config::write_string("TextEditor"sv, "View"sv, "WrappingMode"sv, "Anywhere"sv); }); m_wrap_at_words_action = GUI::Action::create_checkable("Wrap at &Words", [&](auto&) { m_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::WrapAtWords); - Config::write_string("TextEditor", "View", "WrappingMode", "Words"); + Config::write_string("TextEditor"sv, "View"sv, "WrappingMode"sv, "Words"sv); }); m_wrapping_mode_actions.add_action(*m_no_wrapping_action); @@ -454,7 +454,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) wrapping_mode_menu.add_action(*m_wrap_anywhere_action); wrapping_mode_menu.add_action(*m_wrap_at_words_action); - auto word_wrap = Config::read_string("TextEditor", "View", "WrappingMode", "Words"); + auto word_wrap = Config::read_string("TextEditor"sv, "View"sv, "WrappingMode"sv, "Words"sv); if (word_wrap == "None") { m_no_wrapping_action->set_checked(true); m_editor->set_wrapping_mode(GUI::TextEditor::WrappingMode::NoWrap); @@ -610,7 +610,7 @@ void MainWidget::initialize_menubar(GUI::Window& window) help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/TextEditor.md"), "/bin/Help"); })); - help_menu.add_action(GUI::CommonActions::make_about_action("Text Editor", GUI::Icon::default_icon("app-text-editor"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("Text Editor", GUI::Icon::default_icon("app-text-editor"sv), &window)); auto& wrapping_statusbar_menu = m_line_column_statusbar_menu->add_submenu("&Wrapping Mode"); wrapping_statusbar_menu.add_action(*m_no_wrapping_action); @@ -691,10 +691,10 @@ void MainWidget::update_title() { StringBuilder builder; if (m_path.is_empty()) - builder.append("Untitled"); + builder.append("Untitled"sv); else builder.append(m_path); - builder.append("[*] - Text Editor"); + builder.append("[*] - Text Editor"sv); window()->set_title(builder.to_string()); } @@ -742,7 +742,7 @@ void MainWidget::drop_event(GUI::DropEvent& event) if (urls.is_empty()) return; if (urls.size() > 1) { - GUI::MessageBox::show(window(), "TextEditor can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "TextEditor can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error); return; } @@ -854,7 +854,7 @@ void MainWidget::find_text(GUI::TextEditor::SearchDirection direction, ShowMessa if (!result.is_valid() && show_message == ShowMessageIfNoResutls::Yes) { GUI::MessageBox::show(window(), String::formatted("Not found: \"{}\"", needle), - "Not found", + "Not found"sv, GUI::MessageBox::Type::Information); } } diff --git a/Userland/Applications/TextEditor/main.cpp b/Userland/Applications/TextEditor/main.cpp index a291bf46cb0..11e07a79115 100644 --- a/Userland/Applications/TextEditor/main.cpp +++ b/Userland/Applications/TextEditor/main.cpp @@ -24,7 +24,7 @@ ErrorOr serenity_main(Main::Arguments arguments) Config::pledge_domain("TextEditor"); - char const* preview_mode = "auto"; + auto preview_mode = "auto"sv; char const* file_to_edit = nullptr; Core::ArgsParser parser; parser.add_option(preview_mode, "Preview mode, one of 'none', 'html', 'markdown', 'auto'", "preview-mode", '\0', "mode"); @@ -37,9 +37,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/filesystemaccess", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - StringView preview_mode_view = preview_mode; - - auto app_icon = GUI::Icon::default_icon("app-text-editor"); + auto app_icon = GUI::Icon::default_icon("app-text-editor"sv); auto window = TRY(GUI::Window::try_create()); window->resize(640, 400); @@ -54,13 +52,13 @@ ErrorOr serenity_main(Main::Arguments arguments) return GUI::Window::CloseRequestDecision::StayOpen; }; - if (preview_mode_view == "auto") { + if (preview_mode == "auto") { text_widget->set_auto_detect_preview_mode(true); - } else if (preview_mode_view == "markdown") { + } else if (preview_mode == "markdown") { text_widget->set_preview_mode(MainWidget::PreviewMode::Markdown); - } else if (preview_mode_view == "html") { + } else if (preview_mode == "html") { text_widget->set_preview_mode(MainWidget::PreviewMode::HTML); - } else if (preview_mode_view == "none") { + } else if (preview_mode == "none") { text_widget->set_preview_mode(MainWidget::PreviewMode::None); } else { warnln("Invalid mode '{}'", preview_mode); diff --git a/Userland/Applications/ThemeEditor/MainWidget.cpp b/Userland/Applications/ThemeEditor/MainWidget.cpp index 9583d8c2fed..1bc253c7245 100644 --- a/Userland/Applications/ThemeEditor/MainWidget.cpp +++ b/Userland/Applications/ThemeEditor/MainWidget.cpp @@ -208,7 +208,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) { auto file_menu = TRY(window.try_add_menu("&File")); TRY(file_menu->try_add_action(GUI::CommonActions::make_open_action([&](auto&) { - auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Select theme file", "/res/themes"); + auto response = FileSystemAccessClient::Client::the().try_open_file(&window, "Select theme file", "/res/themes"sv); if (response.is_error()) return; load_from_file(*response.value()); @@ -304,7 +304,7 @@ ErrorOr MainWidget::initialize_menubar(GUI::Window& window) TRY(accessibility_menu->try_add_action(achromatomaly_accessibility_action)); auto help_menu = TRY(window.try_add_menu("&Help")); - TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Theme Editor", GUI::Icon::default_icon("app-theme-editor"), &window))); + TRY(help_menu->try_add_action(GUI::CommonActions::make_about_action("Theme Editor", GUI::Icon::default_icon("app-theme-editor"sv), &window))); return {}; } @@ -604,7 +604,7 @@ void MainWidget::set_palette(Gfx::Palette palette) void MainWidget::show_path_picker_dialog(StringView property_display_name, GUI::TextBox& path_input, PathPickerTarget path_picker_target) { bool open_folder = path_picker_target == PathPickerTarget::Folder; - auto window_title = String::formatted(open_folder ? "Select {} folder" : "Select {} file", property_display_name); + auto window_title = String::formatted(open_folder ? "Select {} folder"sv : "Select {} file"sv, property_display_name); auto target_path = path_input.text(); if (Core::File::exists(target_path)) { if (!Core::File::is_directory(target_path)) diff --git a/Userland/Applications/ThemeEditor/PreviewWidget.cpp b/Userland/Applications/ThemeEditor/PreviewWidget.cpp index ea9590c0355..1e9e4b53849 100644 --- a/Userland/Applications/ThemeEditor/PreviewWidget.cpp +++ b/Userland/Applications/ThemeEditor/PreviewWidget.cpp @@ -96,17 +96,17 @@ void PreviewWidget::update_preview_window_locations() void PreviewWidget::paint_preview(GUI::PaintEvent&) { - paint_window("Inactive window", m_inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, active_window_icon()); - paint_window("Active window", m_active_window_rect, Gfx::WindowTheme::WindowState::Active, inactive_window_icon()); + paint_window("Inactive window"sv, m_inactive_window_rect, Gfx::WindowTheme::WindowState::Inactive, active_window_icon()); + paint_window("Active window"sv, m_active_window_rect, Gfx::WindowTheme::WindowState::Active, inactive_window_icon()); } void PreviewWidget::paint_hightlight_window() { GUI::Painter painter(*this); - paint_window("Highlight window", m_highlight_window_rect, Gfx::WindowTheme::WindowState::Highlighted, inactive_window_icon(), 1); + paint_window("Highlight window"sv, m_highlight_window_rect, Gfx::WindowTheme::WindowState::Highlighted, inactive_window_icon(), 1); auto button_rect = Gfx::IntRect(0, 0, 80, 22).centered_within(m_highlight_window_rect); Gfx::StylePainter::paint_button(painter, button_rect, preview_palette(), Gfx::ButtonStyle::Normal, false, false, false, true, false, false); - painter.draw_text(button_rect, ":^)", Gfx::TextAlignment::Center, preview_palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap); + painter.draw_text(button_rect, ":^)"sv, Gfx::TextAlignment::Center, preview_palette().color(foreground_role()), Gfx::TextElision::Right, Gfx::TextWrapping::DontWrap); } void PreviewWidget::second_paint_event(GUI::PaintEvent&) @@ -144,7 +144,7 @@ void PreviewWidget::drop_event(GUI::DropEvent& event) if (urls.is_empty()) return; if (urls.size() > 1) { - GUI::MessageBox::show(window(), "ThemeEditor can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "ThemeEditor can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error); return; } diff --git a/Userland/Applications/ThemeEditor/main.cpp b/Userland/Applications/ThemeEditor/main.cpp index ebfce7407e6..82e13efc317 100644 --- a/Userland/Applications/ThemeEditor/main.cpp +++ b/Userland/Applications/ThemeEditor/main.cpp @@ -51,7 +51,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-theme-editor"); + auto app_icon = GUI::Icon::default_icon("app-theme-editor"sv); auto window = GUI::Window::construct(); auto main_widget = TRY(window->try_set_main_widget()); diff --git a/Userland/Applications/VideoPlayer/main.cpp b/Userland/Applications/VideoPlayer/main.cpp index 9d3f1780825..22c2d103e12 100644 --- a/Userland/Applications/VideoPlayer/main.cpp +++ b/Userland/Applications/VideoPlayer/main.cpp @@ -19,7 +19,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); auto window = TRY(GUI::Window::try_create()); - auto document = Video::MatroskaReader::parse_matroska_from_file("/home/anon/Videos/test-webm.webm"); + auto document = Video::MatroskaReader::parse_matroska_from_file("/home/anon/Videos/test-webm.webm"sv); auto const& optional_track = document->track_for_track_type(Video::TrackEntry::TrackType::Video); if (!optional_track.has_value()) return 1; diff --git a/Userland/Applications/Welcome/WelcomeWidget.cpp b/Userland/Applications/Welcome/WelcomeWidget.cpp index e580d0d7171..0370a2c5470 100644 --- a/Userland/Applications/Welcome/WelcomeWidget.cpp +++ b/Userland/Applications/Welcome/WelcomeWidget.cpp @@ -30,14 +30,14 @@ WelcomeWidget::WelcomeWidget() tip_frame.set_fill_with_background_color(true); auto& light_bulb_label = *find_descendant_of_type_named("light_bulb_label"); - light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png").release_value_but_fixme_should_propagate_errors()); + light_bulb_label.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-welcome.png"sv).release_value_but_fixme_should_propagate_errors()); m_web_view = *find_descendant_of_type_named("web_view"); m_tip_label = *find_descendant_of_type_named("tip_label"); m_next_button = *find_descendant_of_type_named("next_button"); - m_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors()); + m_next_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors()); m_next_button->on_click = [&](auto) { if (!tip_frame.is_visible()) { m_web_view->set_visible(false); @@ -52,7 +52,7 @@ WelcomeWidget::WelcomeWidget() }; m_help_button = *find_descendant_of_type_named("help_button"); - m_help_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors()); + m_help_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); m_help_button->on_click = [&](auto) { GUI::Process::spawn_or_show_error(window(), "/bin/Help"sv); }; @@ -68,11 +68,11 @@ WelcomeWidget::WelcomeWidget() GUI::Application::the()->quit(); }; - auto exec_path = Config::read_string("SystemServer", "Welcome", "Executable", {}); + auto exec_path = Config::read_string("SystemServer"sv, "Welcome"sv, "Executable"sv, {}); m_startup_checkbox = *find_descendant_of_type_named("startup_checkbox"); m_startup_checkbox->set_checked(!exec_path.is_empty()); m_startup_checkbox->on_checked = [](bool is_checked) { - Config::write_string("SystemServer", "Welcome", "Executable", is_checked ? "/bin/Welcome" : ""); + Config::write_string("SystemServer"sv, "Welcome"sv, "Executable"sv, is_checked ? "/bin/Welcome"sv : ""sv); }; open_and_parse_readme_file(); @@ -129,8 +129,8 @@ void WelcomeWidget::paint_event(GUI::PaintEvent& event) GUI::Painter painter(*this); painter.add_clip_rect(event.rect()); - static auto font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"); - painter.draw_text({ 12, 4, 1, 30 }, "Welcome to ", *font, Gfx::TextAlignment::CenterLeft, palette().base_text()); - painter.draw_text({ 12 + font->width("Welcome to "), 4, 1, 30 }, "Serenity", font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base_text()); - painter.draw_text({ 12 + font->width("Welcome to ") + font->bold_variant().width("Serenity"), 4, 1, 30 }, "OS", font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base() == palette().window() ? palette().base_text() : palette().base()); + static auto font = Gfx::BitmapFont::load_from_file("/res/fonts/MarietaRegular24.font"sv); + painter.draw_text({ 12, 4, 1, 30 }, "Welcome to "sv, *font, Gfx::TextAlignment::CenterLeft, palette().base_text()); + painter.draw_text({ 12 + font->width("Welcome to "sv), 4, 1, 30 }, "Serenity"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base_text()); + painter.draw_text({ 12 + font->width("Welcome to "sv) + font->bold_variant().width("Serenity"sv), 4, 1, 30 }, "OS"sv, font->bold_variant(), Gfx::TextAlignment::CenterLeft, palette().base() == palette().window() ? palette().base_text() : palette().base()); } diff --git a/Userland/Applications/Welcome/main.cpp b/Userland/Applications/Welcome/main.cpp index 988e4396385..94f3c1a7c4f 100644 --- a/Userland/Applications/Welcome/main.cpp +++ b/Userland/Applications/Welcome/main.cpp @@ -25,7 +25,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/webcontent", "rw")); TRY(Core::System::unveil("/bin/Help", "x")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-welcome"); + auto app_icon = GUI::Icon::default_icon("app-welcome"sv); auto window = TRY(GUI::Window::try_create()); window->resize(480, 250); diff --git a/Userland/Demos/CatDog/CatDog.cpp b/Userland/Demos/CatDog/CatDog.cpp index 4fd38976022..b4121c344bb 100644 --- a/Userland/Demos/CatDog/CatDog.cpp +++ b/Userland/Demos/CatDog/CatDog.cpp @@ -17,13 +17,13 @@ void CatDog::timer_event(Core::TimerEvent&) auto proc_info = maybe_proc_info.release_value(); auto maybe_paint_program = proc_info.processes.first_matching([](auto& process) { - return process.name.equals_ignoring_case("pixelpaint") || process.name.equals_ignoring_case("fonteditor"); + return process.name.equals_ignoring_case("pixelpaint"sv) || process.name.equals_ignoring_case("fonteditor"sv); }); if (maybe_paint_program.has_value()) { m_main_state = MainState::Artist; } else { auto maybe_inspector_program = proc_info.processes.first_matching([](auto& process) { - return process.name.equals_ignoring_case("inspector") || process.name.equals_ignoring_case("systemmonitor") || process.name.equals_ignoring_case("profiler"); + return process.name.equals_ignoring_case("inspector"sv) || process.name.equals_ignoring_case("systemmonitor"sv) || process.name.equals_ignoring_case("profiler"sv); }); if (maybe_inspector_program.has_value()) diff --git a/Userland/Demos/CatDog/CatDog.h b/Userland/Demos/CatDog/CatDog.h index 25d5d99edb3..6826ec1535a 100644 --- a/Userland/Demos/CatDog/CatDog.h +++ b/Userland/Demos/CatDog/CatDog.h @@ -74,28 +74,28 @@ private: RefPtr m_proc_all; - NonnullRefPtr m_alert = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/alert.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_artist = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/artist.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_erun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_erun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_inspector = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/inspector.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nerun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nerun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nwrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_nwrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_serun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_serun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_sleep1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_sleep2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_srun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_srun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_still = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/still.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_swrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_swrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun2.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_wrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun1.png").release_value_but_fixme_should_propagate_errors(); - NonnullRefPtr m_wrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun2.png").release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_alert = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/alert.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_artist = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/artist.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_erun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_erun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/erun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_inspector = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/inspector.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nerun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nerun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nerun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nrun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nwrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_nwrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/nwrun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_serun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_serun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/serun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_sleep1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_sleep2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/sleep2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_srun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_srun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/srun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_still = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/still.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_swrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_swrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/swrun2.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_wrun1 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun1.png"sv).release_value_but_fixme_should_propagate_errors(); + NonnullRefPtr m_wrun2 = *Gfx::Bitmap::try_load_from_file("/res/icons/catdog/wrun2.png"sv).release_value_but_fixme_should_propagate_errors(); NonnullRefPtr m_curr_bmp = m_alert; diff --git a/Userland/Demos/CatDog/main.cpp b/Userland/Demos/CatDog/main.cpp index 640a5664c9c..8575be8e044 100644 --- a/Userland/Demos/CatDog/main.cpp +++ b/Userland/Demos/CatDog/main.cpp @@ -22,7 +22,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath wpath cpath unix")); auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-catdog")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-catdog"sv)); TRY(Core::System::pledge("stdio recvfd sendfd rpath")); TRY(Core::System::unveil("/res", "r")); diff --git a/Userland/Demos/Cube/Cube.cpp b/Userland/Demos/Cube/Cube.cpp index 5fc00d9812d..83a4fc1589c 100644 --- a/Userland/Demos/Cube/Cube.cpp +++ b/Userland/Demos/Cube/Cube.cpp @@ -225,7 +225,7 @@ ErrorOr serenity_main(Main::Arguments arguments) time->move_by({ window->width() - time->width(), 0 }); cube->set_stat_label(time); - auto app_icon = GUI::Icon::default_icon("app-cube"); + auto app_icon = GUI::Icon::default_icon("app-cube"sv); window->set_icon(app_icon.bitmap_for_size(16)); auto file_menu = TRY(window->try_add_menu("&File")); diff --git a/Userland/Demos/Eyes/main.cpp b/Userland/Demos/Eyes/main.cpp index e308000daad..594cef72d4d 100644 --- a/Userland/Demos/Eyes/main.cpp +++ b/Userland/Demos/Eyes/main.cpp @@ -58,7 +58,7 @@ ErrorOr serenity_main(Main::Arguments arguments) extra_columns = num_eyes % max_in_row; } - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-eyes")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-eyes"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("Eyes"); diff --git a/Userland/Demos/Fire/Fire.cpp b/Userland/Demos/Fire/Fire.cpp index 1592cdba808..6ba086159b3 100644 --- a/Userland/Demos/Fire/Fire.cpp +++ b/Userland/Demos/Fire/Fire.cpp @@ -221,7 +221,7 @@ ErrorOr serenity_main(Main::Arguments arguments) window->show(); - auto app_icon = GUI::Icon::default_icon("app-fire"); + auto app_icon = GUI::Icon::default_icon("app-fire"sv); window->set_icon(app_icon.bitmap_for_size(16)); return app->exec(); diff --git a/Userland/Demos/LibGfxDemo/main.cpp b/Userland/Demos/LibGfxDemo/main.cpp index 123fceb4feb..a72885c4411 100644 --- a/Userland/Demos/LibGfxDemo/main.cpp +++ b/Userland/Demos/LibGfxDemo/main.cpp @@ -107,7 +107,7 @@ void Canvas::draw() painter.draw_line({ 740, 140 }, { 640, 240 }, Color::Red, 5, Gfx::Painter::LineStyle::Solid); painter.draw_line({ 690, 140 }, { 640, 240 }, Color::Blue, 10, Gfx::Painter::LineStyle::Solid); - auto bg = Gfx::Bitmap::try_load_from_file("/res/html/misc/90s-bg.png").release_value_but_fixme_should_propagate_errors(); + auto bg = Gfx::Bitmap::try_load_from_file("/res/html/misc/90s-bg.png"sv).release_value_but_fixme_should_propagate_errors(); painter.draw_tiled_bitmap({ 20, 260, 480, 320 }, *bg); painter.draw_line({ 40, 480 }, { 20, 260 }, Color::Red); @@ -128,33 +128,33 @@ void Canvas::draw() path.close(); painter.fill_path(path, Color::Yellow, Gfx::Painter::WindingRule::EvenOdd); - auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png").release_value_but_fixme_should_propagate_errors(); + auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"sv).release_value_but_fixme_should_propagate_errors(); painter.blit({ 280, 280 }, *buggie, buggie->rect(), 0.5); painter.draw_scaled_bitmap({ 360, 280, buggie->rect().width() * 2, buggie->rect().height() * 2 }, *buggie, buggie->rect()); painter.draw_rect({ 20, 260, 480, 320 }, Color::DarkGray); painter.draw_rect({ 520, 260, 240, 80 }, Color::DarkGray); - painter.draw_text({ 520, 260, 240, 80 }, "CenterLeft", Gfx::TextAlignment::CenterLeft, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "Center", Gfx::TextAlignment::Center, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "CenterRight", Gfx::TextAlignment::CenterRight, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "TopLeft", Gfx::TextAlignment::TopLeft, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "TopRight", Gfx::TextAlignment::TopRight, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "BottomLeft", Gfx::TextAlignment::BottomLeft, Color::White); - painter.draw_text({ 520, 260, 240, 80 }, "BottomRight", Gfx::TextAlignment::BottomRight, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "CenterLeft"sv, Gfx::TextAlignment::CenterLeft, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "Center"sv, Gfx::TextAlignment::Center, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "CenterRight"sv, Gfx::TextAlignment::CenterRight, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "TopLeft"sv, Gfx::TextAlignment::TopLeft, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "TopRight"sv, Gfx::TextAlignment::TopRight, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "BottomLeft"sv, Gfx::TextAlignment::BottomLeft, Color::White); + painter.draw_text({ 520, 260, 240, 80 }, "BottomRight"sv, Gfx::TextAlignment::BottomRight, Color::White); painter.draw_rect({ 520, 360, 240, 30 }, Color::DarkGray); - painter.draw_text({ 520, 360, 240, 30 }, "Emojis! 🙂😂🐞🦄", Gfx::TextAlignment::Center, Color::White); + painter.draw_text({ 520, 360, 240, 30 }, "Emojis! 🙂😂🐞🦄"sv, Gfx::TextAlignment::Center, Color::White); painter.draw_rect({ 520, 410, 240, 80 }, Color::DarkGray); - painter.draw_text({ 520, 415, 240, 20 }, "Normal text", Gfx::FontDatabase::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red); - painter.draw_text({ 520, 430, 240, 20 }, "Bold text", Gfx::FontDatabase::default_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Green); - painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)", Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue); - painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)", Gfx::FontDatabase::default_fixed_width_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Yellow); + painter.draw_text({ 520, 415, 240, 20 }, "Normal text"sv, Gfx::FontDatabase::default_font(), Gfx::TextAlignment::CenterLeft, Color::Red); + painter.draw_text({ 520, 430, 240, 20 }, "Bold text"sv, Gfx::FontDatabase::default_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Green); + painter.draw_text({ 520, 450, 240, 20 }, "Normal text (fixed width)"sv, Gfx::FontDatabase::default_fixed_width_font(), Gfx::TextAlignment::CenterLeft, Color::Blue); + painter.draw_text({ 520, 465, 240, 20 }, "Bold text (fixed width)"sv, Gfx::FontDatabase::default_fixed_width_font().bold_variant(), Gfx::TextAlignment::CenterLeft, Color::Yellow); - auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font"); + auto font = Gfx::BitmapFont::load_from_file("/res/fonts/PebbletonBold14.font"sv); painter.draw_rect({ 520, 510, 240, 30 }, Color::DarkGray); - painter.draw_text({ 520, 510, 240, 30 }, "Hello friends! :^)", *font, Gfx::TextAlignment::Center, Color::White); + painter.draw_text({ 520, 510, 240, 30 }, "Hello friends! :^)"sv, *font, Gfx::TextAlignment::Center, Color::White); painter.fill_rect({ 520, 560, 10, 20 }, Color::White); painter.fill_rect({ 530, 560, 10, 20 }, Color::WarmGray); @@ -198,7 +198,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_menu = TRY(window->try_add_menu("&File")); TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }))); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv)); window->set_icon(app_icon.bitmap_for_size(16)); (void)TRY(window->try_set_main_widget()); window->show(); diff --git a/Userland/Demos/LibGfxScaleDemo/main.cpp b/Userland/Demos/LibGfxScaleDemo/main.cpp index 95bc9e40e4f..32167beb152 100644 --- a/Userland/Demos/LibGfxScaleDemo/main.cpp +++ b/Userland/Demos/LibGfxScaleDemo/main.cpp @@ -74,16 +74,16 @@ void Canvas::paint_event(GUI::PaintEvent& event) void Canvas::draw(Gfx::Painter& painter) { - auto active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors(); + auto active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv).release_value_but_fixme_should_propagate_errors(); - Gfx::WindowTheme::current().paint_normal_frame(painter, Gfx::WindowTheme::WindowState::Active, { 4, 18, WIDTH - 8, HEIGHT - 29 }, "Well hello friends 🐞", *active_window_icon, palette(), { WIDTH - 20, 6, 16, 16 }, 0, false); + Gfx::WindowTheme::current().paint_normal_frame(painter, Gfx::WindowTheme::WindowState::Active, { 4, 18, WIDTH - 8, HEIGHT - 29 }, "Well hello friends 🐞"sv, *active_window_icon, palette(), { WIDTH - 20, 6, 16, 16 }, 0, false); painter.fill_rect({ 4, 25, WIDTH - 8, HEIGHT - 30 }, palette().color(Gfx::ColorRole::Background)); painter.draw_rect({ 20, 34, WIDTH - 40, HEIGHT - 45 }, palette().color(Gfx::ColorRole::Selection), true); painter.draw_rect({ 24, 38, WIDTH - 48, HEIGHT - 53 }, palette().color(Gfx::ColorRole::Selection)); // buggie.png has an alpha channel. - auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png").release_value_but_fixme_should_propagate_errors(); + auto buggie = Gfx::Bitmap::try_load_from_file("/res/graphics/buggie.png"sv).release_value_but_fixme_should_propagate_errors(); painter.blit({ 25, 39 }, *buggie, { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 88, 39, 62 * 2, 20 * 2 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); painter.draw_scaled_bitmap({ 202, 39, 80, 40 }, *buggie, Gfx::IntRect { 2, 30, 62, 20 }); @@ -93,7 +93,7 @@ void Canvas::draw(Gfx::Painter& painter) painter.blit({ 25, 101 }, *buggie, { 2, 30, 3 * buggie->width(), 20 }); // grid does not have an alpha channel. - auto grid = Gfx::Bitmap::try_load_from_file("/res/wallpapers/grid.png").release_value_but_fixme_should_propagate_errors(); + auto grid = Gfx::Bitmap::try_load_from_file("/res/wallpapers/grid.png"sv).release_value_but_fixme_should_propagate_errors(); VERIFY(!grid->has_alpha_channel()); painter.fill_rect({ 25, 122, 62, 20 }, Color::Green); painter.blit({ 25, 122 }, *grid, { (grid->width() - 62) / 2, (grid->height() - 20) / 2 + 40, 62, 20 }, 0.9); @@ -119,7 +119,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file_menu = TRY(window->try_add_menu("&File")); TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }))); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-libgfx-demo"sv)); window->set_icon(app_icon.bitmap_for_size(16)); (void)TRY(window->try_set_main_widget()); window->show(); diff --git a/Userland/Demos/Mandelbrot/Mandelbrot.cpp b/Userland/Demos/Mandelbrot/Mandelbrot.cpp index 932d530dd06..586cd5212d9 100644 --- a/Userland/Demos/Mandelbrot/Mandelbrot.cpp +++ b/Userland/Demos/Mandelbrot/Mandelbrot.cpp @@ -388,7 +388,7 @@ void Mandelbrot::export_image(String const& export_path, ImageType image_type) m_set.resize(size()); auto file = fopen(export_path.characters(), "wb"); if (!file) { - GUI::MessageBox::show(window(), String::formatted("Could not open '{}' for writing.", export_path), "Mandelbrot", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Could not open '{}' for writing.", export_path), "Mandelbrot"sv, GUI::MessageBox::Type::Error); return; } fwrite(encoded_data.data(), 1, encoded_data.size(), file); @@ -439,7 +439,7 @@ ErrorOr serenity_main(Main::Arguments arguments) mandelbrot->export_image(export_path.value(), ImageType::QOI); }))); - export_submenu.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"))); + export_submenu.set_icon(TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/save.png"sv))); TRY(file_menu->try_add_separator()); TRY(file_menu->try_add_action(GUI::CommonActions::make_quit_action([&](auto&) { app->quit(); }))); @@ -463,7 +463,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }, window); - auto app_icon = GUI::Icon::default_icon("app-mandelbrot"); + auto app_icon = GUI::Icon::default_icon("app-mandelbrot"sv); window->set_icon(app_icon.bitmap_for_size(16)); auto view_menu = TRY(window->try_add_menu("&View")); diff --git a/Userland/Demos/ModelGallery/GalleryWidget.cpp b/Userland/Demos/ModelGallery/GalleryWidget.cpp index a3a971dd6ec..30412ff69ae 100644 --- a/Userland/Demos/ModelGallery/GalleryWidget.cpp +++ b/Userland/Demos/ModelGallery/GalleryWidget.cpp @@ -47,8 +47,8 @@ ErrorOr GalleryWidget::load_basic_model_tab() m_add_new_item = *tab->find_descendant_of_type_named("add_new_item"); m_remove_selected_item = *tab->find_descendant_of_type_named("remove_selected_item"); - m_add_new_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors()); - m_remove_selected_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_value_but_fixme_should_propagate_errors()); + m_add_new_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors()); + m_remove_selected_item->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png"sv).release_value_but_fixme_should_propagate_errors()); m_new_item_name->on_return_pressed = [&] { add_textbox_contents_to_basic_model(); }; m_add_new_item->on_click = [&](auto) { add_textbox_contents_to_basic_model(); }; @@ -72,6 +72,6 @@ void GalleryWidget::add_textbox_contents_to_basic_model() { if (!m_new_item_name->current_line().is_empty()) { m_basic_model->add_item(m_new_item_name->current_line().to_utf8()); - m_new_item_name->set_text(""); + m_new_item_name->set_text(""sv); } } diff --git a/Userland/Demos/ModelGallery/main.cpp b/Userland/Demos/ModelGallery/main.cpp index 03d37040db6..42f3e98dc87 100644 --- a/Userland/Demos/ModelGallery/main.cpp +++ b/Userland/Demos/ModelGallery/main.cpp @@ -22,7 +22,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath")); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-model-gallery")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-model-gallery"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("Model Gallery"); diff --git a/Userland/Demos/Mouse/main.cpp b/Userland/Demos/Mouse/main.cpp index 8ae5d9225fe..acc5777307b 100644 --- a/Userland/Demos/Mouse/main.cpp +++ b/Userland/Demos/Mouse/main.cpp @@ -160,7 +160,7 @@ private: ErrorOr serenity_main(Main::Arguments arguments) { auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-mouse")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-mouse"sv)); TRY(Core::System::pledge("stdio recvfd sendfd rpath")); TRY(Core::System::unveil("/res", "r")); diff --git a/Userland/Demos/Screensaver/Screensaver.cpp b/Userland/Demos/Screensaver/Screensaver.cpp index f6ac5149c5e..0199d40e260 100644 --- a/Userland/Demos/Screensaver/Screensaver.cpp +++ b/Userland/Demos/Screensaver/Screensaver.cpp @@ -118,7 +118,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/res", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = GUI::Icon::default_icon("app-screensaver"); + auto app_icon = GUI::Icon::default_icon("app-screensaver"sv); auto window = TRY(GUI::Window::try_create()); window->set_double_buffering_enabled(false); window->set_title("Screensaver"); diff --git a/Userland/Demos/Starfield/Starfield.cpp b/Userland/Demos/Starfield/Starfield.cpp index 8dc4f0a3f3f..59fa4b4adb0 100644 --- a/Userland/Demos/Starfield/Starfield.cpp +++ b/Userland/Demos/Starfield/Starfield.cpp @@ -164,7 +164,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath")); - auto app_icon = GUI::Icon::default_icon("app-starfield"); + auto app_icon = GUI::Icon::default_icon("app-starfield"sv); auto window = TRY(GUI::Window::try_create()); window->set_double_buffering_enabled(true); diff --git a/Userland/Demos/VirGLDemo/VirGLDemo.cpp b/Userland/Demos/VirGLDemo/VirGLDemo.cpp index a653f59bd20..d0716a236d2 100644 --- a/Userland/Demos/VirGLDemo/VirGLDemo.cpp +++ b/Userland/Demos/VirGLDemo/VirGLDemo.cpp @@ -26,26 +26,26 @@ #include "VirGLProtocol.h" #include "Widget.h" -static constexpr StringView frag_shader = "FRAG\n" - "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" - "DCL IN[0], COLOR, COLOR\n" - "DCL OUT[0], COLOR\n" - " 0: MOV OUT[0], IN[0]\n" - " 1: END\n"; +static constexpr auto frag_shader = "FRAG\n" + "PROPERTY FS_COLOR0_WRITES_ALL_CBUFS 1\n" + "DCL IN[0], COLOR, COLOR\n" + "DCL OUT[0], COLOR\n" + " 0: MOV OUT[0], IN[0]\n" + " 1: END\n"sv; -static constexpr StringView vert_shader = "VERT\n" - "DCL IN[0]\n" - "DCL IN[1]\n" - "DCL OUT[0], POSITION\n" - "DCL OUT[1], COLOR\n" - "DCL CONST[0..3]\n" - "DCL TEMP[0..1]\n" - " 0: MUL TEMP[0], IN[0].xxxx, CONST[0]\n" - " 1: MAD TEMP[1], IN[0].yyyy, CONST[1], TEMP[0]\n" - " 2: MAD TEMP[0], IN[0].zzzz, CONST[2], TEMP[1]\n" - " 3: MAD OUT[0], IN[0].wwww, CONST[3], TEMP[0]\n" - " 4: MOV_SAT OUT[1], IN[1]\n" - " 5: END\n"; +static constexpr auto vert_shader = "VERT\n" + "DCL IN[0]\n" + "DCL IN[1]\n" + "DCL OUT[0], POSITION\n" + "DCL OUT[1], COLOR\n" + "DCL CONST[0..3]\n" + "DCL TEMP[0..1]\n" + " 0: MUL TEMP[0], IN[0].xxxx, CONST[0]\n" + " 1: MAD TEMP[1], IN[0].yyyy, CONST[1], TEMP[0]\n" + " 2: MAD TEMP[0], IN[0].zzzz, CONST[2], TEMP[1]\n" + " 3: MAD OUT[0], IN[0].wwww, CONST[3], TEMP[0]\n" + " 4: MOV_SAT OUT[1], IN[1]\n" + " 5: END\n"sv; struct VertexData { float r; @@ -318,7 +318,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto demo = TRY(window->try_set_main_widget()); - auto app_icon = GUI::Icon::default_icon("app-cube"); + auto app_icon = GUI::Icon::default_icon("app-cube"sv); window->set_icon(app_icon.bitmap_for_size(16)); init(); diff --git a/Userland/Demos/WidgetGallery/GalleryModels.h b/Userland/Demos/WidgetGallery/GalleryModels.h index a9b2142c988..ce225ad2902 100644 --- a/Userland/Demos/WidgetGallery/GalleryModels.h +++ b/Userland/Demos/WidgetGallery/GalleryModels.h @@ -64,9 +64,9 @@ public: while (iterator.has_next()) { auto path = iterator.next_full_path(); - if (path.ends_with(".ini")) + if (path.ends_with(".ini"sv)) continue; - if (path.contains("2x")) + if (path.contains("2x"sv)) continue; Cursor cursor; cursor.path = move(path); @@ -155,7 +155,7 @@ public: while (big_iterator.has_next()) { auto path = big_iterator.next_full_path(); - if (!path.contains("filetype-") && !path.contains("app-")) + if (!path.contains("filetype-"sv) && !path.contains("app-"sv)) continue; IconSet icon_set; icon_set.big_icon = Gfx::Bitmap::try_load_from_file(path).release_value_but_fixme_should_propagate_errors(); @@ -169,7 +169,7 @@ public: while (little_iterator.has_next()) { auto path = little_iterator.next_full_path(); - if (!path.contains("filetype-") && !path.contains("app-")) + if (!path.contains("filetype-"sv) && !path.contains("app-"sv)) continue; IconSet icon_set; icon_set.little_icon = Gfx::Bitmap::try_load_from_file(path).release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Demos/WidgetGallery/GalleryWidget.cpp b/Userland/Demos/WidgetGallery/GalleryWidget.cpp index 0fc9aa0ded3..047f442cc20 100644 --- a/Userland/Demos/WidgetGallery/GalleryWidget.cpp +++ b/Userland/Demos/WidgetGallery/GalleryWidget.cpp @@ -72,9 +72,9 @@ GalleryWidget::GalleryWidget() m_label_frame->set_frame_thickness(value); }; - m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png").release_value_but_fixme_should_propagate_errors()); - m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors()); - m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladybug.png").release_value_but_fixme_should_propagate_errors()); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/book-open.png"sv).release_value_but_fixme_should_propagate_errors()); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); + m_button_icons.append(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladybug.png"sv).release_value_but_fixme_should_propagate_errors()); m_icon_button = basics_tab->find_descendant_of_type_named("icon_button"); m_icon_button->set_icon(*m_button_icons[2]); @@ -94,7 +94,7 @@ GalleryWidget::GalleryWidget() m_text_editor = basics_tab->find_descendant_of_type_named("text_editor"); m_font_button = basics_tab->find_descendant_of_type_named("font_button"); - m_font_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors()); + m_font_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors()); m_font_button->on_click = [&](auto) { auto picker = GUI::FontPicker::try_create(window(), &m_text_editor->font(), false).release_value_but_fixme_should_propagate_errors(); @@ -104,7 +104,7 @@ GalleryWidget::GalleryWidget() }; m_file_button = basics_tab->find_descendant_of_type_named("file_button"); - m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors()); + m_file_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); m_file_button->on_click = [&](auto) { Optional open_path = GUI::FilePicker::get_open_filepath(window()); @@ -114,11 +114,11 @@ GalleryWidget::GalleryWidget() }; m_input_button = basics_tab->find_descendant_of_type_named("input_button"); - m_input_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png").release_value_but_fixme_should_propagate_errors()); + m_input_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/properties.png"sv).release_value_but_fixme_should_propagate_errors()); m_input_button->on_click = [&](auto) { String value; - if (GUI::InputBox::show(window(), value, "Enter input:", "Input") == GUI::InputBox::ExecResult::OK && !value.is_empty()) + if (GUI::InputBox::show(window(), value, "Enter input:"sv, "Input"sv) == GUI::InputBox::ExecResult::OK && !value.is_empty()) m_text_editor->set_text(value); }; @@ -132,7 +132,7 @@ GalleryWidget::GalleryWidget() }; m_msgbox_button = basics_tab->find_descendant_of_type_named("msgbox_button"); - m_msgbox_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-browser.png").release_value_but_fixme_should_propagate_errors()); + m_msgbox_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-browser.png"sv).release_value_but_fixme_should_propagate_errors()); m_msgbox_type = GUI::MessageBox::Type::None; m_msgbox_input_type = GUI::MessageBox::InputType::OK; @@ -165,7 +165,7 @@ GalleryWidget::GalleryWidget() }; m_msgbox_button->on_click = [&](auto) { - GUI::MessageBox::show(window(), m_text_editor->text(), "Message", m_msgbox_type, m_msgbox_input_type); + GUI::MessageBox::show(window(), m_text_editor->text(), "Message"sv, m_msgbox_type, m_msgbox_input_type); }; auto sliders_tab = tab_widget.try_add_tab("Sliders").release_value_but_fixme_should_propagate_errors(); @@ -212,7 +212,7 @@ GalleryWidget::GalleryWidget() m_disabled_scrollbar->set_orientation(Orientation::Horizontal); m_opacity_imagewidget = sliders_tab->find_descendant_of_type_named("opacity_imagewidget"); - m_opacity_imagewidget->load_from_file("/res/graphics/brand-banner.png"); + m_opacity_imagewidget->load_from_file("/res/graphics/brand-banner.png"sv); m_opacity_slider = sliders_tab->find_descendant_of_type_named("opacity_slider"); @@ -273,7 +273,7 @@ GalleryWidget::GalleryWidget() m_wizard_button->on_click = [&](auto) { StringBuilder sb; sb.append(m_wizard_output->get_text()); - sb.append("\nWizard started."); + sb.append("\nWizard started."sv); m_wizard_output->set_text(sb.to_string()); auto wizard = DemoWizardDialog::try_create(window()).release_value_but_fixme_should_propagate_errors(); diff --git a/Userland/Demos/WidgetGallery/main.cpp b/Userland/Demos/WidgetGallery/main.cpp index 5e3c5e26ee2..83a0c240996 100644 --- a/Userland/Demos/WidgetGallery/main.cpp +++ b/Userland/Demos/WidgetGallery/main.cpp @@ -22,7 +22,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/home/anon", "r")); TRY(Core::System::unveil("/etc/FileIconProvider.ini", "r")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-widget-gallery")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-widget-gallery"sv)); auto window = TRY(GUI::Window::try_create()); window->resize(430, 480); diff --git a/Userland/DevTools/GMLPlayground/main.cpp b/Userland/DevTools/GMLPlayground/main.cpp index 31e74194c15..6a49c51cf06 100644 --- a/Userland/DevTools/GMLPlayground/main.cpp +++ b/Userland/DevTools/GMLPlayground/main.cpp @@ -48,7 +48,7 @@ UnregisteredWidget::UnregisteredWidget(String const& class_name) { StringBuilder builder; builder.append(class_name); - builder.append("\nnot registered"); + builder.append("\nnot registered"sv); m_text = builder.to_string(); } @@ -77,7 +77,7 @@ ErrorOr serenity_main(Main::Arguments arguments) args_parser.add_positional_argument(path, "GML file to edit", "file", Core::ArgsParser::Required::No); args_parser.parse(arguments); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-gml-playground")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-gml-playground"sv)); auto window = TRY(GUI::Window::try_create()); window->set_title("GML Playground"); window->set_icon(app_icon.bitmap_for_size(16)); @@ -98,14 +98,14 @@ ErrorOr serenity_main(Main::Arguments arguments) auto update_title = [&] { StringBuilder builder; if (file_path.is_empty()) - builder.append("Untitled"); + builder.append("Untitled"sv); else builder.append(file_path); if (window->is_modified()) - builder.append("[*]"); + builder.append("[*]"sv); - builder.append(" - GML Playground"); + builder.append(" - GML Playground"sv); window->set_title(builder.to_string()); }; @@ -128,17 +128,17 @@ ErrorOr serenity_main(Main::Arguments arguments) // Now add some widgets! } -)~~~"); +)~~~"sv); editor->set_cursor(4, 28); // after "...widgets!" update_title(); } else { auto file = Core::File::construct(path); if (!file->open(Core::OpenMode::ReadOnly)) { - GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", path, strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", path, strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return 1; } if (file->is_device()) { - GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", path), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", path), "Error"sv, GUI::MessageBox::Type::Error); return 1; } file_path = path; @@ -154,7 +154,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; if (!editor->write_to_file(new_save_path.value())) { - GUI::MessageBox::show(window, "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } file_path = new_save_path.value(); @@ -164,7 +164,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto save_action = GUI::CommonActions::make_save_action([&](auto&) { if (!file_path.is_empty()) { if (!editor->write_to_file(file_path)) { - GUI::MessageBox::show(window, "Unable to save file.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Unable to save file.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } update_title(); @@ -189,12 +189,12 @@ ErrorOr serenity_main(Main::Arguments arguments) auto file = Core::File::construct(open_path.value()); if (!file->open(Core::OpenMode::ReadOnly) && file->error() != ENOENT) { - GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", open_path.value(), strerror(errno)), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: {}", open_path.value(), strerror(errno)), "Error"sv, GUI::MessageBox::Type::Error); return; } if (file->is_device()) { - GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", open_path.value()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Opening \"{}\" failed: Can't open device files", open_path.value()), "Error"sv, GUI::MessageBox::Type::Error); return; } file_path = open_path.value(); @@ -232,7 +232,7 @@ ErrorOr serenity_main(Main::Arguments arguments) GUI::MessageBox::show( window, String::formatted("GML could not be formatted: {}", formatted_gml_or_error.error()), - "Error", + "Error"sv, GUI::MessageBox::Type::Error); } }))); diff --git a/Userland/DevTools/HackStudio/ClassViewWidget.cpp b/Userland/DevTools/HackStudio/ClassViewWidget.cpp index ee1708b9f37..0a47deb09ec 100644 --- a/Userland/DevTools/HackStudio/ClassViewWidget.cpp +++ b/Userland/DevTools/HackStudio/ClassViewWidget.cpp @@ -130,7 +130,7 @@ static ClassViewNode& add_child_node(NonnullOwnPtrVector& childre void ClassViewModel::add_declaration(CodeComprehension::Declaration const& decl) { ClassViewNode* parent = nullptr; - auto scope_parts = decl.scope.view().split_view("::"); + auto scope_parts = decl.scope.view().split_view("::"sv); if (!scope_parts.is_empty()) { // Traverse declarations tree to the parent of 'decl' diff --git a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp index e1c59113ff5..5fe7bd108f2 100644 --- a/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DebugInfoWidget.cpp @@ -24,19 +24,19 @@ namespace HackStudio { void DebugInfoWidget::init_toolbar() { - m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png").release_value_but_fixme_should_propagate_errors(), [](auto&) { + m_continue_action = GUI::Action::create("Continue", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-continue.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::Continue); }); - m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png").release_value_but_fixme_should_propagate_errors(), [](auto&) { + m_singlestep_action = GUI::Action::create("Step Over", { Mod_None, Key_F10 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-over.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOver); }); - m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png").release_value_but_fixme_should_propagate_errors(), [](auto&) { + m_step_in_action = GUI::Action::create("Step In", { Mod_None, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-in.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceSingleStep); }); - m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png").release_value_but_fixme_should_propagate_errors(), [](auto&) { + m_step_out_action = GUI::Action::create("Step Out", { Mod_Shift, Key_F11 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-step-out.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) { Debugger::the().set_requested_debugger_action(Debugger::DebuggerAction::SourceStepOut); }); @@ -106,7 +106,7 @@ RefPtr DebugInfoWidget::get_context_menu_for_variable(const GUI::Mode if (does_variable_support_writing(variable)) { context_menu->add_action(GUI::Action::create("Change value", [&](auto&) { String value; - if (GUI::InputBox::show(window(), value, "Enter new value:", "Set variable value") == GUI::InputBox::ExecResult::OK) { + if (GUI::InputBox::show(window(), value, "Enter new value:"sv, "Set variable value"sv) == GUI::InputBox::ExecResult::OK) { auto& model = static_cast(*m_variables_view->model()); model.set_variable_value(index, value, window()); } diff --git a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp index 71d8bf39b70..314333626c6 100644 --- a/Userland/DevTools/HackStudio/Debugger/Debugger.cpp +++ b/Userland/DevTools/HackStudio/Debugger/Debugger.cpp @@ -154,7 +154,7 @@ int Debugger::debugger_loop() return Debug::DebugSession::DebugDecision::SingleStep; // We currently do no support stepping through assembly source - if (source_position.value().file_path.ends_with(".S")) + if (source_position.value().file_path.ends_with(".S"sv)) return Debug::DebugSession::DebugDecision::SingleStep; VERIFY(source_position.has_value()); diff --git a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp index 3861ae76262..cf65671ec1b 100644 --- a/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/DisassemblyModel.cpp @@ -34,7 +34,7 @@ DisassemblyModel::DisassemblyModel(Debug::DebugSession const& debug_session, Ptr auto maybe_kernel_base = Symbolication::kernel_base(); if (maybe_kernel_base.has_value() && containing_function.value().address_low >= maybe_kernel_base.value()) { - auto file_or_error = Core::MappedFile::map("/boot/Kernel.debug"); + auto file_or_error = Core::MappedFile::map("/boot/Kernel.debug"sv); if (file_or_error.is_error()) return; kernel_elf = make(file_or_error.value()->bytes()); diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp index 5e014b63c1b..281dd6ba13a 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.cpp @@ -144,7 +144,7 @@ void VariablesModel::set_variable_value(const GUI::ModelIndex& index, StringView GUI::MessageBox::show( parent_window, String::formatted("String value \"{}\" could not be converted to a value of type {}.", string_value, variable->type_name), - "Set value failed", + "Set value failed"sv, GUI::MessageBox::Type::Error); } diff --git a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h index c32019bb318..5ab55a4d823 100644 --- a/Userland/DevTools/HackStudio/Debugger/VariablesModel.h +++ b/Userland/DevTools/HackStudio/Debugger/VariablesModel.h @@ -33,7 +33,7 @@ private: , m_regs(regs) , m_inspector(inspector) { - m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors()); + m_variable_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); } NonnullOwnPtrVector m_variables; PtraceRegisters m_regs; diff --git a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp index 5cc4a85aff3..aab3375734c 100644 --- a/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/NewProjectDialog.cpp @@ -177,20 +177,20 @@ void NewProjectDialog::do_create_project() { auto project_template = selected_template(); if (!project_template) { - GUI::MessageBox::show_error(this, "Could not create project: no template selected."); + GUI::MessageBox::show_error(this, "Could not create project: no template selected."sv); return; } auto maybe_project_name = get_available_project_name(); auto maybe_project_full_path = get_project_full_path(); if (!maybe_project_name.has_value() || !maybe_project_full_path.has_value()) { - GUI::MessageBox::show_error(this, "Could not create project: invalid project name or path."); + GUI::MessageBox::show_error(this, "Could not create project: invalid project name or path."sv); return; } auto create_in = m_create_in_input->text(); if (!Core::File::exists(create_in) || !Core::File::is_directory(create_in)) { - auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto result = GUI::MessageBox::show(this, String::formatted("The directory {} does not exist yet, would you like to create it?", create_in), "New project"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (result != GUI::MessageBox::ExecResult::Yes) return; diff --git a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp index 5f9c61608d4..4b38da2202d 100644 --- a/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp +++ b/Userland/DevTools/HackStudio/Dialogs/ProjectTemplatesModel.cpp @@ -117,7 +117,7 @@ void ProjectTemplatesModel::rescan_templates() while (di.has_next()) { auto full_path = LexicalPath(di.next_full_path()); - if (!full_path.has_extension(".ini")) + if (!full_path.has_extension(".ini"sv)) continue; auto project_template = ProjectTemplate::load_from_manifest(full_path.string()); diff --git a/Userland/DevTools/HackStudio/Editor.cpp b/Userland/DevTools/HackStudio/Editor.cpp index 4ab856ea18f..67e2ff78409 100644 --- a/Userland/DevTools/HackStudio/Editor.cpp +++ b/Userland/DevTools/HackStudio/Editor.cpp @@ -61,7 +61,7 @@ Editor::Editor() if (success) { set_execution_position(cursor().line()); } else { - GUI::MessageBox::show(window(), "Failed to set execution position", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Failed to set execution position"sv, "Error"sv, GUI::MessageBox::Type::Error); } }); @@ -161,13 +161,13 @@ void Editor::paint_event(GUI::PaintEvent& event) if (line < first_visible_line || line > last_visible_line) { continue; } - char const* sign = (line_offset < deletions) ? "!" : "+"; + auto sign = (line_offset < deletions) ? "!"sv : "+"sv; painter.draw_text(gutter_icon_rect(line), sign, font(), Gfx::TextAlignment::Center); } if (additions < deletions) { auto deletions_line = min(finish_line, line_count() - 1); if (deletions_line <= last_visible_line) { - painter.draw_text(gutter_icon_rect(deletions_line), "-", font(), Gfx::TextAlignment::Center); + painter.draw_text(gutter_icon_rect(deletions_line), "-"sv, font(), Gfx::TextAlignment::Center); } } } @@ -224,7 +224,7 @@ void Editor::show_documentation_tooltip_if_available(String const& hovered_token // is probably to tweak Markdown::Document::render_to_html() so we can inject styles // into the rendered HTML easily. html.append(man_document->render_to_html()); - html.append(""); + html.append(""sv); m_documentation_page_view->load_html(html.build(), {}); m_documentation_tooltip_window->move_to(screen_location.translated(4, 4)); @@ -355,7 +355,7 @@ void Editor::drop_event(GUI::DropEvent& event) return; window()->move_to_front(); if (urls.size() > 1) { - GUI::MessageBox::show(window(), "HackStudio can only open one file at a time!", "One at a time please!", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "HackStudio can only open one file at a time!"sv, "One at a time please!"sv, GUI::MessageBox::Type::Error); return; } set_current_editor_wrapper(static_cast(parent())); @@ -433,13 +433,13 @@ void Editor::clear_execution_position() Gfx::Bitmap const& Editor::breakpoint_icon_bitmap() { - static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png").release_value_but_fixme_should_propagate_errors(); + static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/breakpoint.png"sv).release_value_but_fixme_should_propagate_errors(); return *bitmap; } Gfx::Bitmap const& Editor::current_position_icon_bitmap() { - static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(); + static auto bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(); return *bitmap; } @@ -685,17 +685,17 @@ void Editor::handle_function_parameters_hint_request() StringBuilder html; for (size_t i = 0; i < params.size(); ++i) { if (i == argument_index) - html.append(""); + html.append(""sv); html.appendff("{}", params[i]); if (i == argument_index) - html.append(""); + html.append(""sv); if (i < params.size() - 1) - html.append(", "); + html.append(", "sv); } - html.append(""); + html.append(""sv); m_parameter_hint_page_view->load_html(html.build(), {}); diff --git a/Userland/DevTools/HackStudio/EditorWrapper.cpp b/Userland/DevTools/HackStudio/EditorWrapper.cpp index 770c428fe37..45fd8d01f4b 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.cpp +++ b/Userland/DevTools/HackStudio/EditorWrapper.cpp @@ -59,7 +59,7 @@ void EditorWrapper::set_mode_non_displayable() auto palette = editor().palette(); palette.set_color(Gfx::ColorRole::BaseText, Color::from_rgb(0xffffff)); editor().set_palette(palette); - editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"); + editor().document().set_text("The contents of this file could not be displayed. Is it a binary file?"sv); } void EditorWrapper::set_filename(String const& filename) @@ -108,7 +108,7 @@ void EditorWrapper::update_title() title.append(m_filename); if (editor().document().is_modified()) - title.append(" (*)"); + title.append(" (*)"sv); m_filename_title = title.to_string(); } diff --git a/Userland/DevTools/HackStudio/EditorWrapper.h b/Userland/DevTools/HackStudio/EditorWrapper.h index abbc7567380..5b5470cbe93 100644 --- a/Userland/DevTools/HackStudio/EditorWrapper.h +++ b/Userland/DevTools/HackStudio/EditorWrapper.h @@ -57,7 +57,7 @@ public: FindWidget const& find_widget() const { return *m_find_widget; } private: - static constexpr auto untitled_label = "(Untitled)"; + static constexpr auto untitled_label = "(Untitled)"sv; EditorWrapper(); diff --git a/Userland/DevTools/HackStudio/Git/GitWidget.cpp b/Userland/DevTools/HackStudio/Git/GitWidget.cpp index 3723bcbf202..97aeb37d6ad 100644 --- a/Userland/DevTools/HackStudio/Git/GitWidget.cpp +++ b/Userland/DevTools/HackStudio/Git/GitWidget.cpp @@ -32,7 +32,7 @@ GitWidget::GitWidget(String const& repo_root) unstaged_header.set_layout(); auto& refresh_button = unstaged_header.add(); - refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors()); + refresh_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors()); refresh_button.set_fixed_size(16, 16); refresh_button.set_tooltip("refresh"); refresh_button.on_click = [this](int) { refresh(); }; @@ -43,7 +43,7 @@ GitWidget::GitWidget(String const& repo_root) unstaged_header.set_fixed_height(20); m_unstaged_files = unstaged.add( [this](auto const& file) { stage_file(file); }, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png").release_value_but_fixme_should_propagate_errors()); + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/plus.png"sv).release_value_but_fixme_should_propagate_errors()); m_unstaged_files->on_selection_change = [this] { const auto& index = m_unstaged_files->selection().first(); if (!index.is_valid()) @@ -60,7 +60,7 @@ GitWidget::GitWidget(String const& repo_root) staged_header.set_layout(); auto& commit_button = staged_header.add(); - commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png").release_value_but_fixme_should_propagate_errors()); + commit_button.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/commit.png"sv).release_value_but_fixme_should_propagate_errors()); commit_button.set_fixed_size(16, 16); commit_button.set_tooltip("commit"); commit_button.on_click = [this](int) { commit(); }; @@ -71,7 +71,7 @@ GitWidget::GitWidget(String const& repo_root) staged_header.set_fixed_height(20); m_staged_files = staged.add( [this](auto const& file) { unstage_file(file); }, - Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png").release_value_but_fixme_should_propagate_errors()); + Gfx::Bitmap::try_load_from_file("/res/icons/16x16/minus.png"sv).release_value_but_fixme_should_propagate_errors()); } bool GitWidget::initialize() @@ -82,10 +82,10 @@ bool GitWidget::initialize() m_git_repo = result.repo; return true; case GitRepo::CreateResult::Type::GitProgramNotFound: - GUI::MessageBox::show(window(), "Please install the Git port", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Please install the Git port"sv, "Error"sv, GUI::MessageBox::Type::Error); return false; case GitRepo::CreateResult::Type::NoGitRepo: { - auto decision = GUI::MessageBox::show(window(), "Create git repository?", "Git", GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); + auto decision = GUI::MessageBox::show(window(), "Create git repository?"sv, "Git"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (decision != GUI::Dialog::ExecResult::Yes) return false; m_git_repo = GitRepo::initialize_repository(m_repo_root); @@ -136,7 +136,7 @@ void GitWidget::unstage_file(String const& file) void GitWidget::commit() { if (m_git_repo.is_null()) { - GUI::MessageBox::show(window(), "There is no git repository to commit to!", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "There is no git repository to commit to!"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 44f4987202d..b75de6ab22f 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -150,7 +150,7 @@ HackStudioWidget::HackStudioWidget(String path_to_project) m_statusbar = add(3); m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Auto); m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed); - auto width = font().width("Ln 0000, Col 000") + font().max_glyph_width(); + auto width = font().width("Ln 0000, Col 000"sv) + font().max_glyph_width(); m_statusbar->segment(2).set_fixed_width(width); update_statusbar(); @@ -184,7 +184,7 @@ HackStudioWidget::HackStudioWidget(String path_to_project) } m_project_builder = make(*m_terminal_wrapper, *m_project); - project().model().set_should_show_dotfiles(Config::read_bool("HackStudio", "Global", "ShowDotfiles", false)); + project().model().set_should_show_dotfiles(Config::read_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, false)); } void HackStudioWidget::update_actions() @@ -215,7 +215,7 @@ void HackStudioWidget::on_action_tab_change() Vector HackStudioWidget::read_recent_projects() { - auto json = Config::read_string("HackStudio", "Global", "RecentProjects"); + auto json = Config::read_string("HackStudio"sv, "Global"sv, "RecentProjects"sv); AK::JsonParser parser(json); auto value_or_error = parser.parse(); if (value_or_error.is_error()) @@ -279,7 +279,7 @@ void HackStudioWidget::open_project(String const& root_path) if (recent_projects.size() > recent_projects_history_size) recent_projects.shrink(recent_projects_history_size); - Config::write_string("HackStudio", "Global", "RecentProjects", JsonArray(recent_projects).to_string()); + Config::write_string("HackStudio"sv, "Global"sv, "RecentProjects"sv, JsonArray(recent_projects).to_string()); update_recent_projects_submenu(); } @@ -486,7 +486,7 @@ NonnullRefPtr HackStudioWidget::create_project_tree_view_context_menu for (auto& new_file_action : m_new_file_actions) { new_file_submenu.add_action(new_file_action); } - new_file_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors()); + new_file_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors()); new_file_submenu.add_action(*m_new_plain_file_action); new_file_submenu.add_separator(); new_file_submenu.add_action(*m_new_directory_action); @@ -507,7 +507,7 @@ NonnullRefPtr HackStudioWidget::create_new_file_action(String const { return GUI::Action::create(label, Gfx::Bitmap::try_load_from_file(icon).release_value_but_fixme_should_propagate_errors(), [this, extension](const GUI::Action&) { String filename; - if (GUI::InputBox::show(window(), filename, "Enter name of new file:", "Add new file to project") != GUI::InputBox::ExecResult::OK) + if (GUI::InputBox::show(window(), filename, "Enter name of new file:"sv, "Add new file to project"sv) != GUI::InputBox::ExecResult::OK) return; if (!extension.is_empty() && !filename.ends_with(String::formatted(".{}", extension))) { @@ -537,7 +537,7 @@ NonnullRefPtr HackStudioWidget::create_new_file_action(String const auto file = Core::File::construct(filepath); if (!file->open((Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::MustBeNew))) { - GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error"sv, GUI::MessageBox::Type::Error); return; } open_file(filepath); @@ -546,9 +546,9 @@ NonnullRefPtr HackStudioWidget::create_new_file_action(String const NonnullRefPtr HackStudioWidget::create_new_directory_action() { - return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { + return GUI::Action::create("&Directory...", { Mod_Ctrl | Mod_Shift, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/mkdir.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { String directory_name; - if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:", "Add new folder to project") != GUI::InputBox::ExecResult::OK) + if (GUI::InputBox::show(window(), directory_name, "Enter name of new directory:"sv, "Add new folder to project"sv) != GUI::InputBox::ExecResult::OK) return; auto path_to_selected = selected_file_paths(); @@ -569,7 +569,7 @@ NonnullRefPtr HackStudioWidget::create_new_directory_action() auto formatted_dir_name = LexicalPath::canonicalized_path(String::formatted("{}/{}", m_project->model().root_path(), directory_name)); int rc = mkdir(formatted_dir_name.characters(), 0755); if (rc < 0) { - GUI::MessageBox::show(window(), "Failed to create new directory", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Failed to create new directory"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } }); @@ -582,7 +582,7 @@ NonnullRefPtr HackStudioWidget::create_open_selected_action() for (auto& file : files) open_file(file); }); - open_selected_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors()); + open_selected_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); open_selected_action->set_enabled(true); return open_selected_action; } @@ -596,7 +596,7 @@ NonnullRefPtr HackStudioWidget::create_open_selected_in_new_tab_act open_file(file); } }); - open_selected_in_new_tab_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors()); + open_selected_in_new_tab_action->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors()); open_selected_in_new_tab_action->set_enabled(true); return open_selected_in_new_tab_action; } @@ -609,7 +609,7 @@ NonnullRefPtr HackStudioWidget::create_show_in_file_manager_action( Desktop::Launcher::open(URL::create_with_file_protocol(m_project->root_path(), file)); }); show_in_file_manager_action->set_enabled(true); - show_in_file_manager_action->set_icon(GUI::Icon::default_icon("app-file-manager").bitmap_for_size(16)); + show_in_file_manager_action->set_icon(GUI::Icon::default_icon("app-file-manager"sv).bitmap_for_size(16)); return show_in_file_manager_action; } @@ -623,7 +623,7 @@ NonnullRefPtr HackStudioWidget::create_copy_relative_path_action() GUI::Clipboard::the().set_plain_text(paths_string); }); copy_relative_path_action->set_enabled(true); - copy_relative_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16)); + copy_relative_path_action->set_icon(GUI::Icon::default_icon("hard-disk"sv).bitmap_for_size(16)); return copy_relative_path_action; } @@ -640,7 +640,7 @@ NonnullRefPtr HackStudioWidget::create_copy_full_path_action() GUI::Clipboard::the().set_plain_text(paths_string); }); copy_full_path_action->set_enabled(true); - copy_full_path_action->set_icon(GUI::Icon::default_icon("hard-disk").bitmap_for_size(16)); + copy_full_path_action->set_icon(GUI::Icon::default_icon("hard-disk"sv).bitmap_for_size(16)); return copy_full_path_action; } @@ -662,7 +662,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() auto result = GUI::MessageBox::show(window(), message, - "Confirm deletion", + "Confirm deletion"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::OKCancel); if (result == GUI::MessageBox::ExecResult::Cancel) @@ -673,7 +673,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() if (lstat(file.characters(), &st) < 0) { GUI::MessageBox::show(window(), String::formatted("lstat ({}) failed: {}", file, strerror(errno)), - "Removal failed", + "Removal failed"sv, GUI::MessageBox::Type::Error); break; } @@ -684,12 +684,12 @@ NonnullRefPtr HackStudioWidget::create_delete_action() if (is_directory) { GUI::MessageBox::show(window(), String::formatted("Removing directory {} from the project failed: {}", error.file, static_cast(error)), - "Removal failed", + "Removal failed"sv, GUI::MessageBox::Type::Error); } else { GUI::MessageBox::show(window(), String::formatted("Removing file {} from the project failed: {}", error.file, static_cast(error)), - "Removal failed", + "Removal failed"sv, GUI::MessageBox::Type::Error); } } @@ -702,7 +702,7 @@ NonnullRefPtr HackStudioWidget::create_delete_action() NonnullRefPtr HackStudioWidget::create_new_project_action() { - return GUI::Action::create("&Project...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png").release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { + return GUI::Action::create("&Project...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/hackstudio-project.png"sv).release_value_but_fixme_should_propagate_errors(), [this](const GUI::Action&) { auto dialog = NewProjectDialog::construct(window()); dialog->set_icon(window()->icon()); auto result = dialog->exec(); @@ -848,7 +848,7 @@ NonnullRefPtr HackStudioWidget::create_switch_to_previous_editor_ac NonnullRefPtr HackStudioWidget::create_remove_current_editor_action() { - return GUI::Action::create("&Remove Current Editor", { Mod_Alt | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-editor.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("&Remove Current Editor", { Mod_Alt | Mod_Shift, Key_E }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (m_all_editor_wrappers.size() <= 1) return; auto tab_widget = m_current_editor_tab_widget; @@ -861,7 +861,7 @@ NonnullRefPtr HackStudioWidget::create_remove_current_editor_action NonnullRefPtr HackStudioWidget::create_open_action() { - return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("&Open Project...", { Mod_Ctrl | Mod_Shift, Key_O }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { auto open_path = GUI::FilePicker::get_open_filepath(window(), "Open project", m_project->root_path(), true); if (!open_path.has_value()) return; @@ -892,8 +892,8 @@ NonnullRefPtr HackStudioWidget::create_save_as_action() LexicalPath const old_path(old_filename); Optional save_path = GUI::FilePicker::get_save_filepath(window(), - old_filename.is_null() ? "Untitled" : old_path.title(), - old_filename.is_null() ? "txt" : old_path.extension(), + old_filename.is_null() ? "Untitled"sv : old_path.title(), + old_filename.is_null() ? "txt"sv : old_path.extension(), Core::File::absolute_path(old_path.dirname())); if (!save_path.has_value()) { return; @@ -927,7 +927,7 @@ NonnullRefPtr HackStudioWidget::create_save_as_action() NonnullRefPtr HackStudioWidget::create_remove_current_terminal_action() { - return GUI::Action::create("Remove &Current Terminal", { Mod_Alt | Mod_Shift, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-terminal.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("Remove &Current Terminal", { Mod_Alt | Mod_Shift, Key_T }, Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/remove-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { auto widget = m_action_tab_widget->active_widget(); if (!widget) return; @@ -953,7 +953,7 @@ NonnullRefPtr HackStudioWidget::create_add_editor_tab_widget_action NonnullRefPtr HackStudioWidget::create_add_editor_action() { return GUI::Action::create("Add New &Editor", { Mod_Ctrl | Mod_Alt, Key_E }, - Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-editor.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { add_new_editor(*m_current_editor_tab_widget); update_actions(); @@ -963,7 +963,7 @@ NonnullRefPtr HackStudioWidget::create_add_editor_action() NonnullRefPtr HackStudioWidget::create_add_terminal_action() { return GUI::Action::create("Add New &Terminal", { Mod_Ctrl | Mod_Alt, Key_T }, - Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-terminal.png").release_value_but_fixme_should_propagate_errors(), + Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/add-terminal.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { auto& terminal_wrapper = m_action_tab_widget->add_tab("Terminal"); terminal_wrapper.on_command_exit = [&]() { @@ -986,13 +986,13 @@ void HackStudioWidget::reveal_action_tab(GUI::Widget& widget) NonnullRefPtr HackStudioWidget::create_debug_action() { - return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("&Debug", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/debug-run.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (!Core::File::exists(get_project_executable_path())) { - GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error"sv, GUI::MessageBox::Type::Error); return; } if (Debugger::the().session()) { - GUI::MessageBox::show(window(), "Debugger is already running", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), "Debugger is already running"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -1073,7 +1073,7 @@ void HackStudioWidget::initialize_debugger() } HackStudioWidget::hide_action_tabs(); - GUI::MessageBox::show(window(), "Program Exited", "Debugger", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), "Program Exited"sv, "Debugger"sv, GUI::MessageBox::Type::Information); }); Core::EventLoop::wake_current(); }); @@ -1096,7 +1096,7 @@ String HackStudioWidget::get_absolute_path(String const& path) const { // TODO: We can probably do a more specific condition here, something like // "if (file.starts_with("../Libraries/") || file.starts_with("../AK/"))" - if (path.starts_with("..")) { + if (path.starts_with(".."sv)) { return get_full_path_of_serenity_source(path); } return m_project->to_absolute_path(path); @@ -1106,7 +1106,7 @@ RefPtr HackStudioWidget::get_editor_of_file(String const& filenam { String file_path = filename; - if (filename.starts_with("../")) { + if (filename.starts_with("../"sv)) { file_path = get_full_path_of_serenity_source(filename); } @@ -1127,7 +1127,7 @@ void HackStudioWidget::build() { auto result = m_project_builder->build(active_file()); if (result.is_error()) { - GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Build failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Build failed"sv, GUI::MessageBox::Type::Error); m_build_action->set_enabled(true); m_stop_action->set_enabled(false); } else { @@ -1139,7 +1139,7 @@ void HackStudioWidget::run() { auto result = m_project_builder->run(active_file()); if (result.is_error()) { - GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Run failed", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window(), String::formatted("{}", result.error()), "Run failed"sv, GUI::MessageBox::Type::Error); m_run_action->set_enabled(true); m_stop_action->set_enabled(false); } else { @@ -1279,7 +1279,7 @@ void HackStudioWidget::create_toolbar(GUI::Widget& parent) NonnullRefPtr HackStudioWidget::create_build_action() { - return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("&Build", { Mod_Ctrl, Key_B }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/build.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (warn_unsaved_changes("There are unsaved changes, do you want to save before building?") == ContinueDecision::No) return; @@ -1290,7 +1290,7 @@ NonnullRefPtr HackStudioWidget::create_build_action() NonnullRefPtr HackStudioWidget::create_run_action() { - return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + return GUI::Action::create("&Run", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-run.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { reveal_action_tab(*m_terminal_wrapper); run(); }); @@ -1388,14 +1388,14 @@ void HackStudioWidget::create_file_menu(GUI::Window& window) for (auto& new_file_action : m_new_file_actions) { new_submenu.add_action(new_file_action); } - new_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors()); + new_submenu.set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors()); new_submenu.add_action(*m_new_plain_file_action); new_submenu.add_separator(); new_submenu.add_action(*m_new_directory_action); file_menu.add_action(*m_open_action); m_recent_projects_submenu = &file_menu.add_submenu("Open &Recent"); - m_recent_projects_submenu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-recent.png").release_value_but_fixme_should_propagate_errors()); + m_recent_projects_submenu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/open-recent.png"sv).release_value_but_fixme_should_propagate_errors()); update_recent_projects_submenu(); file_menu.add_action(*m_save_action); file_menu.add_action(*m_save_as_action); @@ -1408,7 +1408,7 @@ void HackStudioWidget::create_file_menu(GUI::Window& window) void HackStudioWidget::create_edit_menu(GUI::Window& window) { auto& edit_menu = window.add_menu("&Edit"); - edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + edit_menu.add_action(GUI::Action::create("&Find in Files...", { Mod_Ctrl | Mod_Shift, Key_F }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/find.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { reveal_action_tab(*m_find_in_files_widget); m_find_in_files_widget->focus_textbox_and_select_all(); })); @@ -1452,9 +1452,9 @@ void HackStudioWidget::create_view_menu(GUI::Window& window) }); auto show_dotfiles_action = GUI::Action::create_checkable("S&how Dotfiles", { Mod_Ctrl, Key_H }, [&](auto& checked) { project().model().set_should_show_dotfiles(checked.is_checked()); - Config::write_bool("HackStudio", "Global", "ShowDotfiles", checked.is_checked()); + Config::write_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, checked.is_checked()); }); - show_dotfiles_action->set_checked(Config::read_bool("HackStudio", "Global", "ShowDotfiles", false)); + show_dotfiles_action->set_checked(Config::read_bool("HackStudio"sv, "Global"sv, "ShowDotfiles"sv, false)); auto& view_menu = window.add_menu("&View"); view_menu.add_action(hide_action_tabs_action); @@ -1489,7 +1489,7 @@ void HackStudioWidget::create_view_menu(GUI::Window& window) m_no_wrapping_action->set_checked(true); - m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png").release_value_but_fixme_should_propagate_errors(), + m_editor_font_action = GUI::Action::create("Editor &Font...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-font-editor.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { auto picker = GUI::FontPicker::construct(&window, m_editor_font, false); if (picker->exec() == GUI::Dialog::ExecResult::OK) { @@ -1520,12 +1520,12 @@ void HackStudioWidget::create_view_menu(GUI::Window& window) void HackStudioWidget::create_help_menu(GUI::Window& window) { auto& help_menu = window.add_menu("&Help"); - help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"), &window)); + help_menu.add_action(GUI::CommonActions::make_about_action("Hack Studio", GUI::Icon::default_icon("app-hack-studio"sv), &window)); } NonnullRefPtr HackStudioWidget::create_stop_action() { - auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + auto action = GUI::Action::create("&Stop", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/program-stop.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (!Debugger::the().session()) { if (auto result = m_terminal_wrapper->kill_running_command(); result.is_error()) warnln("{}", result.error()); @@ -1605,7 +1605,7 @@ HackStudioWidget::ContinueDecision HackStudioWidget::warn_unsaved_changes(String if (!any_document_is_dirty()) return ContinueDecision::Yes; - auto result = GUI::MessageBox::show(window(), prompt, "Unsaved changes", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); + auto result = GUI::MessageBox::show(window(), prompt, "Unsaved changes"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNoCancel); if (result == GUI::MessageBox::ExecResult::Cancel) return ContinueDecision::No; @@ -1630,7 +1630,7 @@ bool HackStudioWidget::any_document_is_dirty() const void HackStudioWidget::update_gml_preview() { - auto gml_content = current_editor_wrapper().filename().ends_with(".gml") ? current_editor_wrapper().editor().text() : ""; + auto gml_content = current_editor_wrapper().filename().ends_with(".gml"sv) ? current_editor_wrapper().editor().text().view() : ""sv; m_gml_preview_widget->load_gml(gml_content); } @@ -1685,7 +1685,7 @@ void HackStudioWidget::on_cursor_change() void HackStudioWidget::create_location_history_actions() { - m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_locations_history_back_action = GUI::Action::create("Go Back", { Mod_Alt | Mod_Shift, Key_Left }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (m_locations_history_end_index <= 1) return; @@ -1699,7 +1699,7 @@ void HackStudioWidget::create_location_history_actions() update_history_actions(); }); - m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_locations_history_forward_action = GUI::Action::create("Go Forward", { Mod_Alt | Mod_Shift, Key_Right }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { if (m_locations_history_end_index == m_locations_history.size()) return; @@ -1717,7 +1717,7 @@ void HackStudioWidget::create_location_history_actions() NonnullRefPtr HackStudioWidget::create_open_project_configuration_action() { - return GUI::Action::create("Project Configuration", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png").release_value(), [&](auto&) { + return GUI::Action::create("Project Configuration", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv).release_value(), [&](auto&) { auto parent_directory = LexicalPath::dirname(Project::config_file_path); auto absolute_config_file_path = LexicalPath::absolute_path(m_project->root_path(), Project::config_file_path); @@ -1734,7 +1734,7 @@ NonnullRefPtr HackStudioWidget::create_open_project_configuration_a "{\n" " \"build_command\": \"your build command here\",\n" " \"run_command\": \"your run command here\"\n" - "}\n"); + "}\n"sv); file.value()->close(); } @@ -1762,9 +1762,9 @@ void HackStudioWidget::update_history_actions() RefPtr HackStudioWidget::read_editor_font_from_config() { - auto font_family = Config::read_string("HackStudio", "EditorFont", "Family", "Csilla"); - auto font_variant = Config::read_string("HackStudio", "EditorFont", "Variant", "Regular"); - auto font_size = Config::read_i32("HackStudio", "EditorFont", "Size", 10); + auto font_family = Config::read_string("HackStudio"sv, "EditorFont"sv, "Family"sv, "Csilla"sv); + auto font_variant = Config::read_string("HackStudio"sv, "EditorFont"sv, "Variant"sv, "Regular"sv); + auto font_size = Config::read_i32("HackStudio"sv, "EditorFont"sv, "Size"sv, 10); auto font = Gfx::FontDatabase::the().get(font_family, font_variant, font_size); if (font.is_null()) @@ -1780,9 +1780,9 @@ void HackStudioWidget::change_editor_font(RefPtr font) editor_wrapper.editor().set_font(*m_editor_font); } - Config::write_string("HackStudio", "EditorFont", "Family", m_editor_font->family()); - Config::write_string("HackStudio", "EditorFont", "Variant", m_editor_font->variant()); - Config::write_i32("HackStudio", "EditorFont", "Size", m_editor_font->presentation_size()); + Config::write_string("HackStudio"sv, "EditorFont"sv, "Family"sv, m_editor_font->family()); + Config::write_string("HackStudio"sv, "EditorFont"sv, "Variant"sv, m_editor_font->variant()); + Config::write_i32("HackStudio"sv, "EditorFont"sv, "Size"sv, m_editor_font->presentation_size()); } void HackStudioWidget::open_coredump(String const& coredump_path) @@ -1810,7 +1810,7 @@ void HackStudioWidget::for_each_open_file(Function fun NonnullRefPtr HackStudioWidget::create_toggle_syntax_highlighting_mode_action() { - auto action = GUI::Action::create_checkable("&Semantic Highlighting", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-cplusplus.png").release_value_but_fixme_should_propagate_errors(), [this](auto& action) { + auto action = GUI::Action::create_checkable("&Semantic Highlighting", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/filetype-cplusplus.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto& action) { for (auto& editor_wrapper : m_all_editor_wrappers) editor_wrapper.editor().set_semantic_syntax_highlighting(action.is_checked()); }); diff --git a/Userland/DevTools/HackStudio/LanguageClient.cpp b/Userland/DevTools/HackStudio/LanguageClient.cpp index ff43b93a988..4b87233ab61 100644 --- a/Userland/DevTools/HackStudio/LanguageClient.cpp +++ b/Userland/DevTools/HackStudio/LanguageClient.cpp @@ -209,7 +209,7 @@ void ConnectionToServerWrapper::on_crash() void ConnectionToServerWrapper::show_frequent_crashes_notification() const { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors()); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors()); notification->set_title("LanguageServer Crashes too much!"); notification->set_text("LanguageServer aided features will not be available in this session"); notification->show(); @@ -217,7 +217,7 @@ void ConnectionToServerWrapper::show_frequent_crashes_notification() const void ConnectionToServerWrapper::show_crash_notification() const { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors()); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors()); notification->set_title("Oops!"); notification->set_text(String::formatted("LanguageServer has crashed")); notification->show(); diff --git a/Userland/DevTools/HackStudio/Project.cpp b/Userland/DevTools/HackStudio/Project.cpp index 97660392813..f13139c5ae9 100644 --- a/Userland/DevTools/HackStudio/Project.cpp +++ b/Userland/DevTools/HackStudio/Project.cpp @@ -63,7 +63,7 @@ bool Project::project_is_serenity() const { // FIXME: Improve this heuristic // Running "Meta/serenity.sh copy-src" installs the serenity repository at this path in the home directory - return m_root_path.ends_with("Source/serenity"); + return m_root_path.ends_with("Source/serenity"sv); } NonnullOwnPtr Project::config() const diff --git a/Userland/DevTools/HackStudio/Project.h b/Userland/DevTools/HackStudio/Project.h index 53069481f41..7d32ec953de 100644 --- a/Userland/DevTools/HackStudio/Project.h +++ b/Userland/DevTools/HackStudio/Project.h @@ -33,7 +33,7 @@ public: String to_absolute_path(String const&) const; bool project_is_serenity() const; - static constexpr StringView config_file_path = ".hackstudio/config.json"; + static constexpr auto config_file_path = ".hackstudio/config.json"sv; NonnullOwnPtr config() const; private: diff --git a/Userland/DevTools/HackStudio/ProjectBuilder.cpp b/Userland/DevTools/HackStudio/ProjectBuilder.cpp index 0a0d007b5e4..4abacd86853 100644 --- a/Userland/DevTools/HackStudio/ProjectBuilder.cpp +++ b/Userland/DevTools/HackStudio/ProjectBuilder.cpp @@ -34,7 +34,7 @@ ErrorOr ProjectBuilder::build(StringView active_file) if (active_file.is_null()) return Error::from_string_literal("no active file"); - if (active_file.ends_with(".js")) { + if (active_file.ends_with(".js"sv)) { TRY(m_terminal->run_command(String::formatted("js -A {}", active_file))); return {}; } @@ -60,7 +60,7 @@ ErrorOr ProjectBuilder::run(StringView active_file) if (active_file.is_null()) return Error::from_string_literal("no active file"); - if (active_file.ends_with(".js")) { + if (active_file.ends_with(".js"sv)) { TRY(m_terminal->run_command(String::formatted("js {}", active_file))); return {}; } @@ -129,7 +129,7 @@ ErrorOr ProjectBuilder::initialize_build_directory() } } - auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt").string(); + auto cmake_file_path = LexicalPath::join(build_directory(), "CMakeLists.txt"sv).string(); if (Core::File::exists(cmake_file_path)) MUST(Core::File::remove(cmake_file_path, Core::File::RecursionMode::Disallowed, false)); @@ -148,7 +148,7 @@ Optional ProjectBuilder::find_cmake_file_for(StringView file_path) const { auto directory = LexicalPath::dirname(file_path); while (!directory.is_empty()) { - auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt"); + auto cmake_path = LexicalPath::join(m_project_root, directory, "CMakeLists.txt"sv); if (Core::File::exists(cmake_path.string())) return cmake_path.string(); directory = LexicalPath::dirname(directory); diff --git a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp index 82bc0afe766..7413ae89f06 100644 --- a/Userland/DevTools/HackStudio/ProjectDeclarations.cpp +++ b/Userland/DevTools/HackStudio/ProjectDeclarations.cpp @@ -20,13 +20,13 @@ void HackStudio::ProjectDeclarations::set_declared_symbols(String const& filenam Optional HackStudio::ProjectDeclarations::get_icon_for(CodeComprehension::DeclarationType type) { - static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png").release_value_but_fixme_should_propagate_errors()); - static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png").release_value_but_fixme_should_propagate_errors()); + static GUI::Icon struct_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Struct.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon class_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Class.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon function_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Function.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon variable_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Variable.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon preprocessor_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Preprocessor.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon member_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Member.png"sv).release_value_but_fixme_should_propagate_errors()); + static GUI::Icon namespace_icon(Gfx::Bitmap::try_load_from_file("/res/icons/hackstudio/Namespace.png"sv).release_value_but_fixme_should_propagate_errors()); switch (type) { case CodeComprehension::DeclarationType::Struct: return struct_icon; diff --git a/Userland/DevTools/HackStudio/ProjectTemplate.cpp b/Userland/DevTools/HackStudio/ProjectTemplate.cpp index f8a38224144..a4b64df8b32 100644 --- a/Userland/DevTools/HackStudio/ProjectTemplate.cpp +++ b/Userland/DevTools/HackStudio/ProjectTemplate.cpp @@ -48,7 +48,7 @@ RefPtr ProjectTemplate::load_from_manifest(String const& manife // Attempt to read in the template icons // Fallback to a generic executable icon if one isn't found - auto icon = GUI::Icon::default_icon("filetype-executable"); + auto icon = GUI::Icon::default_icon("filetype-executable"sv); auto bitmap_path_32 = String::formatted("/res/icons/hackstudio/templates-32x32/{}.png", config->read_entry("HackStudioTemplate", "IconName32x")); @@ -94,7 +94,7 @@ Result ProjectTemplate::create_project(String const& name, String dbgln("Running post-create script '{}'", postcreate_script_path); // Generate a namespace-safe project name (replace hyphens with underscores) - auto namespace_safe = name.replace("-", "_", ReplaceMode::All); + auto namespace_safe = name.replace("-"sv, "_"sv, ReplaceMode::All); pid_t child_pid; char const* argv[] = { postcreate_script_path.characters(), name.characters(), path.characters(), namespace_safe.characters(), nullptr }; diff --git a/Userland/DevTools/HackStudio/TerminalWrapper.cpp b/Userland/DevTools/HackStudio/TerminalWrapper.cpp index af9a4585e26..bb9ed98c3a8 100644 --- a/Userland/DevTools/HackStudio/TerminalWrapper.cpp +++ b/Userland/DevTools/HackStudio/TerminalWrapper.cpp @@ -28,8 +28,8 @@ ErrorOr TerminalWrapper::run_command(String const& command, Optional TerminalWrapper::setup_master_pseudoterminal(WaitForChildOnExit wai if (WIFEXITED(wstatus)) { m_terminal_widget->inject_string(String::formatted("\033[{};1m(Command exited with code {})\033[0m\r\n", wstatus == 0 ? 32 : 31, WEXITSTATUS(wstatus))); } else if (WIFSTOPPED(wstatus)) { - m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"); + m_terminal_widget->inject_string("\033[34;1m(Command stopped!)\033[0m\r\n"sv); } else if (WIFSIGNALED(wstatus)) { m_terminal_widget->inject_string(String::formatted("\033[34;1m(Command signaled with {}!)\033[0m\r\n", strsignal(WTERMSIG(wstatus)))); } diff --git a/Userland/DevTools/HackStudio/main.cpp b/Userland/DevTools/HackStudio/main.cpp index fd23ec8027d..69b8f80fd0a 100644 --- a/Userland/DevTools/HackStudio/main.cpp +++ b/Userland/DevTools/HackStudio/main.cpp @@ -43,7 +43,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = GUI::Window::construct(); window->resize(840, 600); - window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png").release_value_but_fixme_should_propagate_errors()); + window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors()); update_path_environment_variable(); @@ -112,7 +112,7 @@ static bool make_is_available() static void notify_make_not_available() { auto notification = GUI::Notification::construct(); - notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png").release_value_but_fixme_should_propagate_errors()); + notification->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/app-hack-studio.png"sv).release_value_but_fixme_should_propagate_errors()); notification->set_title("'make' Not Available"); notification->set_text("You probably want to install the binutils, gcc, and make ports from the root of the Serenity repository"); notification->show(); @@ -128,7 +128,7 @@ static void update_path_environment_variable() if (path.length()) path.append(":"); - path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"); + path.append("/usr/local/sbin:/usr/local/bin:/usr/bin:/bin"sv); setenv("PATH", path.to_string().characters(), true); } diff --git a/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp b/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp index 33b1c445c57..254731d23ec 100644 --- a/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp +++ b/Userland/DevTools/Inspector/RemoteObjectGraphModel.cpp @@ -17,10 +17,10 @@ namespace Inspector { RemoteObjectGraphModel::RemoteObjectGraphModel(RemoteProcess& process) : m_process(process) { - m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors()); - m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors()); - m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png").release_value_but_fixme_should_propagate_errors()); - m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/timer.png").release_value_but_fixme_should_propagate_errors()); + m_object_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); + m_window_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv).release_value_but_fixme_should_propagate_errors()); + m_layout_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/layout.png"sv).release_value_but_fixme_should_propagate_errors()); + m_timer_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/timer.png"sv).release_value_but_fixme_should_propagate_errors()); } GUI::ModelIndex RemoteObjectGraphModel::index(int row, int column, const GUI::ModelIndex& parent) const @@ -82,7 +82,7 @@ GUI::Variant RemoteObjectGraphModel::data(const GUI::ModelIndex& index, GUI::Mod return m_window_icon; if (remote_object->class_name == "Timer") return m_timer_icon; - if (remote_object->class_name.ends_with("Layout")) + if (remote_object->class_name.ends_with("Layout"sv)) return m_layout_icon; return m_object_icon; } diff --git a/Userland/DevTools/Inspector/RemoteProcess.cpp b/Userland/DevTools/Inspector/RemoteProcess.cpp index 5bb52c020be..1f2f96c49d0 100644 --- a/Userland/DevTools/Inspector/RemoteProcess.cpp +++ b/Userland/DevTools/Inspector/RemoteProcess.cpp @@ -29,10 +29,10 @@ RemoteProcess::RemoteProcess(pid_t pid) void RemoteProcess::handle_identify_response(JsonObject const& response) { - int pid = response.get("pid").to_int(); + int pid = response.get("pid"sv).to_int(); VERIFY(pid == m_pid); - m_process_name = response.get("process_name").as_string_or({}); + m_process_name = response.get("process_name"sv).as_string_or({}); if (on_update) on_update(); @@ -41,7 +41,7 @@ void RemoteProcess::handle_identify_response(JsonObject const& response) void RemoteProcess::handle_get_all_objects_response(JsonObject const& response) { // FIXME: It would be good if we didn't have to make a local copy of the array value here! - auto objects = response.get("objects"); + auto objects = response.get("objects"sv); auto& object_array = objects.as_array(); NonnullOwnPtrVector remote_objects; @@ -51,10 +51,10 @@ void RemoteProcess::handle_get_all_objects_response(JsonObject const& response) VERIFY(value.is_object()); auto& object = value.as_object(); auto remote_object = make(); - remote_object->address = object.get("address").to_number(); - remote_object->parent_address = object.get("parent").to_number(); - remote_object->name = object.get("name").to_string(); - remote_object->class_name = object.get("class_name").to_string(); + remote_object->address = object.get("address"sv).to_number(); + remote_object->parent_address = object.get("parent"sv).to_number(); + remote_object->name = object.get("name"sv).to_string(); + remote_object->class_name = object.get("class_name"sv).to_string(); remote_object->json = object; objects_by_address.set(remote_object->address, remote_object); remote_objects.append(move(remote_object)); diff --git a/Userland/DevTools/Inspector/main.cpp b/Userland/DevTools/Inspector/main.cpp index 512cb7bfdf1..bf0fce471c0 100644 --- a/Userland/DevTools/Inspector/main.cpp +++ b/Userland/DevTools/Inspector/main.cpp @@ -48,10 +48,10 @@ ErrorOr serenity_main(Main::Arguments arguments) pid_t pid; auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-inspector")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-inspector"sv)); if (gui_mode) { choose_pid: - auto process_chooser = TRY(GUI::ProcessChooser::try_create("Inspector", "Inspect", app_icon.bitmap_for_size(16))); + auto process_chooser = TRY(GUI::ProcessChooser::try_create("Inspector"sv, "Inspect"sv, app_icon.bitmap_for_size(16))); if (process_chooser->exec() == GUI::Dialog::ExecResult::Cancel) return 0; pid = process_chooser->pid(); @@ -65,13 +65,13 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::Window::try_create()); if (pid == getpid()) { - GUI::MessageBox::show(window, "Cannot inspect Inspector itself!", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Cannot inspect Inspector itself!"sv, "Error"sv, GUI::MessageBox::Type::Error); return 1; } RemoteProcess remote_process(pid); if (!remote_process.is_inspectable()) { - GUI::MessageBox::show(window, String::formatted("Process pid={} is not inspectable", remote_process.pid()), "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, String::formatted("Process pid={} is not inspectable", remote_process.pid()), "Error"sv, GUI::MessageBox::Type::Error); if (gui_mode) { goto choose_pid; } else { @@ -126,7 +126,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto properties_tree_view_context_menu = TRY(GUI::Menu::try_create("Properties Tree View")); - auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png").release_value_but_fixme_should_propagate_errors(); + auto copy_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/edit-copy.png"sv).release_value_but_fixme_should_propagate_errors(); auto copy_property_name_action = GUI::Action::create("Copy Property Name", copy_bitmap, [&](auto&) { GUI::Clipboard::the().set_plain_text(properties_tree_view.selection().first().data().to_string()); }); diff --git a/Userland/DevTools/Profiler/DisassemblyModel.cpp b/Userland/DevTools/Profiler/DisassemblyModel.cpp index 3411a31069e..0aa11e39dfb 100644 --- a/Userland/DevTools/Profiler/DisassemblyModel.cpp +++ b/Userland/DevTools/Profiler/DisassemblyModel.cpp @@ -24,7 +24,7 @@ static ELF::Image* try_load_kernel_binary() { if (s_kernel_binary.has_value()) return &s_kernel_binary->elf; - auto kernel_binary_or_error = Core::MappedFile::map("/boot/Kernel"); + auto kernel_binary_or_error = Core::MappedFile::map("/boot/Kernel"sv); if (!kernel_binary_or_error.is_error()) { auto kernel_binary = kernel_binary_or_error.release_value(); s_kernel_binary = { { kernel_binary, ELF::Image(kernel_binary->bytes()) } }; @@ -212,12 +212,12 @@ GUI::Variant DisassemblyModel::data(GUI::ModelIndex const& index, GUI::ModelRole if (first) first = false; else - builder.append(" => "); + builder.append(" => "sv); builder.appendff("{}:{}", entry.file_path, entry.line_number); } if (insn.source_position_with_inlines.source_position.has_value()) { if (!first) - builder.append(" => "); + builder.append(" => "sv); auto const& entry = insn.source_position_with_inlines.source_position.value(); builder.appendff("{}:{}", entry.file_path, entry.line_number); } diff --git a/Userland/DevTools/Profiler/Profile.cpp b/Userland/DevTools/Profiler/Profile.cpp index a510cc67379..d4acc406d88 100644 --- a/Userland/DevTools/Profiler/Profile.cpp +++ b/Userland/DevTools/Profiler/Profile.cpp @@ -245,7 +245,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path auto const& object = json.value().as_object(); if (!g_kernel_debuginfo_object.has_value()) { - auto debuginfo_file_or_error = Core::MappedFile::map("/boot/Kernel.debug"); + auto debuginfo_file_or_error = Core::MappedFile::map("/boot/Kernel.debug"sv); if (!debuginfo_file_or_error.is_error()) { auto debuginfo_file = debuginfo_file_or_error.release_value(); auto debuginfo_image = ELF::Image(debuginfo_file->bytes()); @@ -263,7 +263,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path profile_strings.set(string_id, value.to_string()); } - auto const* events_value = object.get_ptr("events"); + auto const* events_value = object.get_ptr("events"sv); if (!events_value || !events_value->is_array()) return Error::from_string_literal("Malformed profile (events is not an array)"); @@ -281,12 +281,12 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path event.serial = next_serial; next_serial.increment(); - event.timestamp = perf_event.get("timestamp").to_number(); - event.lost_samples = perf_event.get("lost_samples").to_number(); - event.pid = perf_event.get("pid").to_i32(); - event.tid = perf_event.get("tid").to_i32(); + event.timestamp = perf_event.get("timestamp"sv).to_number(); + event.lost_samples = perf_event.get("lost_samples"sv).to_number(); + event.pid = perf_event.get("pid"sv).to_i32(); + event.tid = perf_event.get("tid"sv).to_i32(); - auto type_string = perf_event.get("type").to_string(); + auto type_string = perf_event.get("type"sv).to_string(); if (type_string == "sample"sv) { event.data = Event::SampleData {}; @@ -403,7 +403,7 @@ ErrorOr> Profile::load_from_perfcore_file(StringView path auto maybe_kernel_base = Symbolication::kernel_base(); - auto const* stack = perf_event.get_ptr("stack"); + auto const* stack = perf_event.get_ptr("stack"sv); VERIFY(stack); auto const& stack_array = stack->as_array(); for (ssize_t i = stack_array.values().size() - 1; i >= 0; --i) { diff --git a/Userland/DevTools/Profiler/ProfileModel.cpp b/Userland/DevTools/Profiler/ProfileModel.cpp index 23cc815fbfb..73904100821 100644 --- a/Userland/DevTools/Profiler/ProfileModel.cpp +++ b/Userland/DevTools/Profiler/ProfileModel.cpp @@ -16,8 +16,8 @@ namespace Profiler { ProfileModel::ProfileModel(Profile& profile) : m_profile(profile) { - m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors()); - m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors()); + m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); + m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png"sv).release_value_but_fixme_should_propagate_errors()); } GUI::ModelIndex ProfileModel::index(int row, int column, GUI::ModelIndex const& parent) const diff --git a/Userland/DevTools/Profiler/SamplesModel.cpp b/Userland/DevTools/Profiler/SamplesModel.cpp index a37aec04d99..e6dd0f005ab 100644 --- a/Userland/DevTools/Profiler/SamplesModel.cpp +++ b/Userland/DevTools/Profiler/SamplesModel.cpp @@ -14,8 +14,8 @@ namespace Profiler { SamplesModel::SamplesModel(Profile& profile) : m_profile(profile) { - m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png").release_value_but_fixme_should_propagate_errors()); - m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png").release_value_but_fixme_should_propagate_errors()); + m_user_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object.png"sv).release_value_but_fixme_should_propagate_errors()); + m_kernel_frame_icon.set_bitmap_for_size(16, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/inspector-object-red.png"sv).release_value_but_fixme_should_propagate_errors()); } int SamplesModel::row_count(GUI::ModelIndex const&) const diff --git a/Userland/DevTools/Profiler/SourceModel.cpp b/Userland/DevTools/Profiler/SourceModel.cpp index 42067464a91..912d4a2ce24 100644 --- a/Userland/DevTools/Profiler/SourceModel.cpp +++ b/Userland/DevTools/Profiler/SourceModel.cpp @@ -27,7 +27,7 @@ public: public: SourceFile(StringView filename) { - String source_file_name = filename.replace("../../", source_root_path, ReplaceMode::FirstOnly); + String source_file_name = filename.replace("../../"sv, source_root_path, ReplaceMode::FirstOnly); auto maybe_file = Core::File::open(source_file_name, Core::OpenMode::ReadOnly); if (maybe_file.is_error()) { diff --git a/Userland/DevTools/Profiler/main.cpp b/Userland/DevTools/Profiler/main.cpp index 8ea601987ea..92c934b1de4 100644 --- a/Userland/DevTools/Profiler/main.cpp +++ b/Userland/DevTools/Profiler/main.cpp @@ -58,7 +58,7 @@ ErrorOr serenity_main(Main::Arguments arguments) } auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-profiler"sv)); String perfcore_file; if (!perfcore_file_arg) { @@ -71,7 +71,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto profile_or_error = Profile::load_from_perfcore_file(perfcore_file); if (profile_or_error.is_error()) { - GUI::MessageBox::show(nullptr, String::formatted("{}", profile_or_error.error()), "Profiler", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, String::formatted("{}", profile_or_error.error()), "Profiler"sv, GUI::MessageBox::Type::Error); return 0; } @@ -170,12 +170,12 @@ ErrorOr serenity_main(Main::Arguments arguments) update_source_model(); }; - auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) { + auto disassembly_action = GUI::Action::create_checkable("Show &Disassembly", { Mod_Ctrl, Key_D }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) { disassembly_view->set_visible(action.is_checked()); update_disassembly_model(); }); - auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png").release_value_but_fixme_should_propagate_errors(), [&](auto& action) { + auto source_action = GUI::Action::create_checkable("Show &Source", { Mod_Ctrl, Key_S }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/x86.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto& action) { source_view->set_visible(action.is_checked()); update_source_model(); }); @@ -314,7 +314,7 @@ static bool prompt_to_stop_profiling(pid_t pid, String const& process_name) auto window = GUI::Window::construct(); window->set_title(String::formatted("Profiling {}({})", process_name, pid)); window->resize(240, 100); - window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors()); + window->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors()); window->center_on_screen(); auto& widget = window->set_main_widget(); @@ -342,7 +342,7 @@ static bool prompt_to_stop_profiling(pid_t pid, String const& process_name) bool generate_profile(pid_t& pid) { if (!pid) { - auto process_chooser = GUI::ProcessChooser::construct("Profiler", "Profile", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png").release_value_but_fixme_should_propagate_errors()); + auto process_chooser = GUI::ProcessChooser::construct("Profiler"sv, "Profile"sv, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-profiler.png"sv).release_value_but_fixme_should_propagate_errors()); if (process_chooser->exec() == GUI::Dialog::ExecResult::Cancel) return false; pid = process_chooser->pid(); @@ -366,7 +366,7 @@ bool generate_profile(pid_t& pid) if (profiling_enable(pid, event_mask) < 0) { int saved_errno = errno; - GUI::MessageBox::show(nullptr, String::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(nullptr, String::formatted("Unable to profile process {}({}): {}", process_name, pid, strerror(saved_errno)), "Profiler"sv, GUI::MessageBox::Type::Error); return false; } diff --git a/Userland/DevTools/SQLStudio/MainWidget.cpp b/Userland/DevTools/SQLStudio/MainWidget.cpp index 56f84c37ac1..027d51c085c 100644 --- a/Userland/DevTools/SQLStudio/MainWidget.cpp +++ b/Userland/DevTools/SQLStudio/MainWidget.cpp @@ -35,7 +35,7 @@ MainWidget::MainWidget() set_fill_with_background_color(true); set_layout(); - m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png").release_value_but_fixme_should_propagate_errors(), [this](auto&) { + m_new_action = GUI::Action::create("&New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/new.png"sv).release_value_but_fixme_should_propagate_errors(), [this](auto&) { open_new_script(); }); @@ -142,7 +142,7 @@ MainWidget::MainWidget() update_editor_actions(editor); }); - m_run_script_action = GUI::Action::create("Run script", { Mod_Alt, Key_F9 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + m_run_script_action = GUI::Action::create("Run script", { Mod_Alt, Key_F9 }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { m_results.clear(); m_current_line_for_parsing = 0; // TODO select the database to use in UI. @@ -207,10 +207,10 @@ MainWidget::MainWidget() m_statusbar = add(3); m_statusbar->segment(1).set_mode(GUI::Statusbar::Segment::Mode::Fixed); - m_statusbar->segment(1).set_fixed_width(font().width("000000 characters (00000 words) selected") + font().max_glyph_width()); + m_statusbar->segment(1).set_fixed_width(font().width("000000 characters (00000 words) selected"sv) + font().max_glyph_width()); m_statusbar->segment(2).set_mode(GUI::Statusbar::Segment::Mode::Fixed); - m_statusbar->segment(2).set_fixed_width(font().width("Ln 0000, Col 000") + font().max_glyph_width()); + m_statusbar->segment(2).set_fixed_width(font().width("Ln 0000, Col 000"sv) + font().max_glyph_width()); m_sql_client = SQL::SQLClient::try_create().release_value_but_fixme_should_propagate_errors(); m_sql_client->on_execution_success = [this](int, bool, int, int, int) { @@ -266,7 +266,7 @@ void MainWidget::initialize_menu(GUI::Window* window) help_menu.add_action(GUI::CommonActions::make_help_action([](auto&) { Desktop::Launcher::open(URL::create_with_file_protocol("/usr/share/man/man1/SQLStudio.md"), "/bin/Help"); })); - help_menu.add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"), window)); + help_menu.add_action(GUI::CommonActions::make_about_action("SQL Studio", GUI::Icon::default_icon("app-sql-studio"sv), window)); } void MainWidget::open_new_script() @@ -394,7 +394,7 @@ void MainWidget::drop_event(GUI::DropEvent& drop_event) for (auto& url : urls) { auto& scheme = url.scheme(); - if (!scheme.equals_ignoring_case("file")) + if (!scheme.equals_ignoring_case("file"sv)) continue; auto lexical_path = LexicalPath(url.path()); diff --git a/Userland/DevTools/SQLStudio/main.cpp b/Userland/DevTools/SQLStudio/main.cpp index cc2c709ab00..c08746ccdb9 100644 --- a/Userland/DevTools/SQLStudio/main.cpp +++ b/Userland/DevTools/SQLStudio/main.cpp @@ -23,7 +23,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = GUI::Icon::default_icon("app-sql-studio"); + auto app_icon = GUI::Icon::default_icon("app-sql-studio"sv); auto window = TRY(GUI::Window::try_create()); window->resize(640, 480); diff --git a/Userland/DevTools/UserspaceEmulator/Emulator.cpp b/Userland/DevTools/UserspaceEmulator/Emulator.cpp index e78ba56772a..57b8bbc8af5 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator.cpp @@ -85,7 +85,7 @@ Vector Emulator::generate_auxiliary_vector(FlatPtr load_bas auxv.append({ ELF::AuxiliaryValue::Entry, (void*)entry_eip }); // FIXME: Don't hard code this? We might support other platforms later.. (e.g. x86_64) - auxv.append({ ELF::AuxiliaryValue::Platform, "i386" }); + auxv.append({ ELF::AuxiliaryValue::Platform, "i386"sv }); auxv.append({ ELF::AuxiliaryValue::ExecFilename, executable_path }); @@ -154,7 +154,7 @@ bool Emulator::load_elf() { auto file_or_error = Core::MappedFile::map(m_executable_path); if (file_or_error.is_error()) { - reportln("Unable to map {}: {}", m_executable_path, file_or_error.error()); + reportln("Unable to map {}: {}"sv, m_executable_path, file_or_error.error()); return false; } @@ -169,7 +169,7 @@ bool Emulator::load_elf() StringBuilder interpreter_path_builder; auto result_or_error = ELF::validate_program_headers(*(Elf32_Ehdr const*)elf_image_data.data(), elf_image_data.size(), elf_image_data, &interpreter_path_builder); if (result_or_error.is_error() || !result_or_error.value()) { - reportln("failed to validate ELF file"); + reportln("failed to validate ELF file"sv); return false; } auto interpreter_path = interpreter_path_builder.string_view(); @@ -229,7 +229,7 @@ int Emulator::exec() size_t instructions_until_next_profile_dump = profile_instruction_interval(); if (is_profiling() && m_loader_text_size.has_value()) - emit_profile_event(profile_stream(), "mmap", String::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size)); + emit_profile_event(profile_stream(), "mmap"sv, String::formatted(R"("ptr": {}, "size": {}, "name": "/usr/lib/Loader.so")", *m_loader_text_base, *m_loader_text_size)); while (!m_shutdown) { if (m_steps_til_pause) [[likely]] { @@ -493,7 +493,7 @@ String Emulator::create_backtrace_line(FlatPtr address) void Emulator::dump_backtrace(Vector const& backtrace) { for (auto const& address : backtrace) { - reportln("{}", create_backtrace_line(address)); + reportln("{}"sv, create_backtrace_line(address)); } } @@ -511,7 +511,7 @@ void Emulator::emit_profile_sample(AK::OutputStream& output) gettimeofday(&tv, nullptr); builder.appendff(R"~(, {{"type": "sample", "pid": {}, "tid": {}, "timestamp": {}, "lost_samples": 0, "stack": [)~", getpid(), gettid(), tv.tv_sec * 1000 + tv.tv_usec / 1000); builder.join(',', raw_backtrace()); - builder.append("]}\n"); + builder.append("]}\n"sv); output.write_or_error(builder.string_view().bytes()); } @@ -626,7 +626,7 @@ void Emulator::dispatch_one_pending_signal() auto action = default_signal_action(signum); if (action == DefaultSignalAction::Ignore) return; - reportln("\n=={}== Got signal {} ({}), no handler registered", getpid(), signum, strsignal(signum)); + reportln("\n=={}== Got signal {} ({}), no handler registered"sv, getpid(), signum, strsignal(signum)); dump_backtrace(); m_shutdown = true; return; @@ -637,7 +637,7 @@ void Emulator::dispatch_one_pending_signal() return; } - reportln("\n=={}== Got signal {} ({}), handler at {:p}", getpid(), signum, strsignal(signum), handler.handler); + reportln("\n=={}== Got signal {} ({}), handler at {:p}"sv, getpid(), signum, strsignal(signum), handler.handler); auto old_esp = m_cpu->esp().value(); @@ -762,7 +762,7 @@ void Emulator::setup_signal_trampoline() void Emulator::dump_regions() const { const_cast(m_mmu).for_each_region([&](Region const& region) { - reportln("{:p}-{:p} {:c}{:c}{:c} {} {}{}{} ", + reportln("{:p}-{:p} {:c}{:c}{:c} {} {}{}{} "sv, region.base(), region.end() - 1, region.is_readable() ? 'R' : '-', diff --git a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp index 8d42441ef56..f1fe167ad48 100644 --- a/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp +++ b/Userland/DevTools/UserspaceEmulator/Emulator_syscalls.cpp @@ -38,7 +38,7 @@ namespace UserspaceEmulator { u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) { if constexpr (SPAM_DEBUG) - reportln("Syscall: {} ({:x})", Syscall::to_string((Syscall::Function)function), function); + reportln("Syscall: {} ({:x})"sv, Syscall::to_string((Syscall::Function)function), function); switch (function) { case SC_accept4: return virt$accept4(arg1); @@ -261,7 +261,7 @@ u32 Emulator::virt_syscall(u32 function, u32 arg1, u32 arg2, u32 arg3) case SC_write: return virt$write(arg1, arg2, arg3); default: - reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}", getpid(), Syscall::to_string((Syscall::Function)function), function); + reportln("\n=={}== \033[31;1mUnimplemented syscall: {}\033[0m, {:p}"sv, getpid(), Syscall::to_string((Syscall::Function)function), function); dump_backtrace(); TODO(); } @@ -297,7 +297,7 @@ FlatPtr Emulator::virt$perf_event(int event, FlatPtr arg1, FlatPtr arg2) if (event == PERF_EVENT_SIGNPOST) { if (is_profiling()) { if (profiler_string_id_map().size() > arg1) - emit_profile_event(profile_stream(), "signpost", String::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2)); + emit_profile_event(profile_stream(), "signpost"sv, String::formatted("\"arg1\": {}, \"arg2\": {}", arg1, arg2)); syscall(SC_perf_event, PERF_EVENT_SIGNPOST, profiler_string_id_map().at(arg1), arg2); } else { syscall(SC_perf_event, PERF_EVENT_SIGNPOST, arg1, arg2); @@ -846,7 +846,7 @@ static void round_to_page_size(FlatPtr& address, size_t& size) u32 Emulator::virt$munmap(FlatPtr address, size_t size) { if (is_profiling()) - emit_profile_event(profile_stream(), "munmap", String::formatted("\"ptr\": {}, \"size\": {}", address, size)); + emit_profile_event(profile_stream(), "munmap"sv, String::formatted("\"ptr\": {}, \"size\": {}", address, size)); round_to_page_size(address, size); Vector marked_for_deletion; bool has_non_mmap_region = false; @@ -894,7 +894,7 @@ u32 Emulator::virt$mmap(u32 params_addr) } else { // mmap(nullptr, …, MAP_FIXED) is technically okay, but tends to be a bug. // Therefore, refuse to be helpful. - reportln("\n=={}== \033[31;1mTried to mmap at nullptr with MAP_FIXED.\033[0m, {:#x} bytes.", getpid(), params.size); + reportln("\n=={}== \033[31;1mTried to mmap at nullptr with MAP_FIXED.\033[0m, {:#x} bytes."sv, getpid(), params.size); dump_backtrace(); } } else { @@ -916,7 +916,7 @@ u32 Emulator::virt$mmap(u32 params_addr) } if (is_profiling()) - emit_profile_event(profile_stream(), "mmap", String::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str)); + emit_profile_event(profile_stream(), "mmap"sv, String::formatted(R"("ptr": {}, "size": {}, "name": "{}")", final_address, final_size, name_str)); if (params.flags & MAP_ANONYMOUS) { mmu().add_region(MmapRegion::create_anonymous(final_address, final_size, params.prot, move(name_str))); @@ -1082,7 +1082,7 @@ void Emulator::virt$sync() void Emulator::virt$exit(int status) { - reportln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!", getpid(), status); + reportln("\n=={}== \033[33;1mSyscall: exit({})\033[0m, shutting down!"sv, getpid(), status); m_exit_status = status; m_shutdown = true; } @@ -1173,7 +1173,7 @@ int Emulator::virt$ioctl([[maybe_unused]] int fd, unsigned request, [[maybe_unus return syscall(SC_ioctl, fd, request, &enabled); } default: - reportln("Unsupported ioctl: {}", request); + reportln("Unsupported ioctl: {}"sv, request); dump_backtrace(); TODO(); } @@ -1245,10 +1245,10 @@ int Emulator::virt$execve(FlatPtr params_addr) copy_string_list(arguments, params.arguments); copy_string_list(environment, params.environment); - reportln("\n=={}== \033[33;1mSyscall:\033[0m execve", getpid()); - reportln("=={}== @ {}", getpid(), path); + reportln("\n=={}== \033[33;1mSyscall:\033[0m execve"sv, getpid()); + reportln("=={}== @ {}"sv, getpid(), path); for (auto& argument : arguments) - reportln("=={}== - {}", getpid(), argument); + reportln("=={}== - {}"sv, getpid(), argument); if (access(path.characters(), X_OK) < 0) { if (errno == ENOENT || errno == EACCES) @@ -1336,7 +1336,7 @@ int Emulator::virt$gethostname(FlatPtr buffer, ssize_t buffer_size) int Emulator::virt$sigaction(int signum, FlatPtr act, FlatPtr oldact) { if (signum == SIGKILL) { - reportln("Attempted to sigaction() with SIGKILL"); + reportln("Attempted to sigaction() with SIGKILL"sv); return -EINVAL; } diff --git a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp index 2ba544f9af3..a31c8a6ba78 100644 --- a/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp +++ b/Userland/DevTools/UserspaceEmulator/MallocTracer.cpp @@ -130,8 +130,8 @@ void MallocTracer::target_did_free(Badge, FlatPtr address) if (auto* mallocation = find_mallocation(address)) { if (mallocation->freed) { - reportln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}", getpid(), address); - reportln("=={}== Address {} has already been passed to free()", getpid(), address); + reportln("\n=={}== \033[31;1mDouble free()\033[0m, {:p}"sv, getpid(), address); + reportln("=={}== Address {} has already been passed to free()"sv, getpid(), address); m_emulator.dump_backtrace(); } else { mallocation->freed = true; @@ -140,8 +140,8 @@ void MallocTracer::target_did_free(Badge, FlatPtr address) return; } - reportln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}", getpid(), address); - reportln("=={}== Address {} has never been returned by malloc()", getpid(), address); + reportln("\n=={}== \033[31;1mInvalid free()\033[0m, {:p}"sv, getpid(), address); + reportln("=={}== Address {} has never been returned by malloc()"sv, getpid(), address); m_emulator.dump_backtrace(); } @@ -228,19 +228,19 @@ void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size auto* mallocation = find_mallocation(region, address); if (!mallocation) { - reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); + reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte read at address {:p}"sv, getpid(), size, address); m_emulator.dump_backtrace(); auto* mallocation_before = find_mallocation_before(address); auto* mallocation_after = find_mallocation_after(address); size_t distance_to_mallocation_before = mallocation_before ? (address - mallocation_before->address - mallocation_before->size) : 0; size_t distance_to_mallocation_after = mallocation_after ? (mallocation_after->address - address) : 0; if (mallocation_before && (!mallocation_after || distance_to_mallocation_before < distance_to_mallocation_after)) { - reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address); + reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address); m_emulator.dump_backtrace(mallocation_before->malloc_backtrace); return; } if (mallocation_after && (!mallocation_before || distance_to_mallocation_after < distance_to_mallocation_before)) { - reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address); + reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address); m_emulator.dump_backtrace(mallocation_after->malloc_backtrace); } return; @@ -249,11 +249,11 @@ void MallocTracer::audit_read(Region const& region, FlatPtr address, size_t size size_t offset_into_mallocation = address - mallocation->address; if (mallocation->freed) { - reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}", getpid(), size, address); + reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte read at address {:p}"sv, getpid(), size, address); m_emulator.dump_backtrace(); - reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); + reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:"sv, getpid(), offset_into_mallocation, mallocation->size); m_emulator.dump_backtrace(mallocation->malloc_backtrace); - reportln("=={}== Later freed at:", getpid()); + reportln("=={}== Later freed at:"sv, getpid()); m_emulator.dump_backtrace(mallocation->free_backtrace); return; } @@ -274,19 +274,19 @@ void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t siz auto* mallocation = find_mallocation(region, address); if (!mallocation) { - reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); + reportln("\n=={}== \033[31;1mHeap buffer overflow\033[0m, invalid {}-byte write at address {:p}"sv, getpid(), size, address); m_emulator.dump_backtrace(); auto* mallocation_before = find_mallocation_before(address); auto* mallocation_after = find_mallocation_after(address); size_t distance_to_mallocation_before = mallocation_before ? (address - mallocation_before->address - mallocation_before->size) : 0; size_t distance_to_mallocation_after = mallocation_after ? (mallocation_after->address - address) : 0; if (mallocation_before && (!mallocation_after || distance_to_mallocation_before < distance_to_mallocation_after)) { - reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address); + reportln("=={}== Address is {} byte(s) after block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_before, mallocation_before->size, mallocation_before->address); m_emulator.dump_backtrace(mallocation_before->malloc_backtrace); return; } if (mallocation_after && (!mallocation_before || distance_to_mallocation_after < distance_to_mallocation_before)) { - reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:", getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address); + reportln("=={}== Address is {} byte(s) before block of size {}, identity {:p}, allocated at:"sv, getpid(), distance_to_mallocation_after, mallocation_after->size, mallocation_after->address); m_emulator.dump_backtrace(mallocation_after->malloc_backtrace); } return; @@ -295,11 +295,11 @@ void MallocTracer::audit_write(Region const& region, FlatPtr address, size_t siz size_t offset_into_mallocation = address - mallocation->address; if (mallocation->freed) { - reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}", getpid(), size, address); + reportln("\n=={}== \033[31;1mUse-after-free\033[0m, invalid {}-byte write at address {:p}"sv, getpid(), size, address); m_emulator.dump_backtrace(); - reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:", getpid(), offset_into_mallocation, mallocation->size); + reportln("=={}== Address is {} byte(s) into block of size {}, allocated at:"sv, getpid(), offset_into_mallocation, mallocation->size); m_emulator.dump_backtrace(mallocation->malloc_backtrace); - reportln("=={}== Later freed at:", getpid()); + reportln("=={}== Later freed at:"sv, getpid()); m_emulator.dump_backtrace(mallocation->free_backtrace); return; } @@ -329,7 +329,7 @@ void MallocTracer::populate_memory_graph() auto other_address = value.value(); if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) { if constexpr (REACHABLE_DEBUG) - reportln("region/mallocation {:p} is reachable from other mallocation {:p}", other_address, mallocation.address); + reportln("region/mallocation {:p} is reachable from other mallocation {:p}"sv, other_address, mallocation.address); edges_from_mallocation.edges_from_node.append(other_address); } } @@ -357,7 +357,7 @@ void MallocTracer::populate_memory_graph() auto other_address = value.value(); if (!value.is_uninitialized() && m_memory_graph.contains(value.value())) { if constexpr (REACHABLE_DEBUG) - reportln("region/mallocation {:p} is reachable from region {:p}-{:p}", other_address, region.base(), region.end() - 1); + reportln("region/mallocation {:p} is reachable from region {:p}-{:p}"sv, other_address, region.base(), region.end() - 1); m_memory_graph.find(other_address)->value.is_reachable = true; reachable_mallocations.append(other_address); } @@ -417,14 +417,14 @@ void MallocTracer::dump_leak_report() return IterationDecision::Continue; ++leaks_found; bytes_leaked += mallocation.size; - reportln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}", getpid(), mallocation.size, mallocation.address); + reportln("\n=={}== \033[31;1mLeak\033[0m, {}-byte allocation at address {:p}"sv, getpid(), mallocation.size, mallocation.address); m_emulator.dump_backtrace(mallocation.malloc_backtrace); return IterationDecision::Continue; }); if (!leaks_found) - reportln("\n=={}== \033[32;1mNo leaks found!\033[0m", getpid()); + reportln("\n=={}== \033[32;1mNo leaks found!\033[0m"sv, getpid()); else - reportln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m", getpid(), leaks_found, bytes_leaked); + reportln("\n=={}== \033[31;1m{} leak(s) found: {} byte(s) leaked\033[0m"sv, getpid(), leaks_found, bytes_leaked); } } diff --git a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp index 9c525c6ec94..bfd31253def 100644 --- a/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp +++ b/Userland/DevTools/UserspaceEmulator/MmapRegion.cpp @@ -65,7 +65,7 @@ MmapRegion::~MmapRegion() ValueWithShadow MmapRegion::read8(FlatPtr offset) { if (!is_readable()) { - reportln("8-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("8-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -82,7 +82,7 @@ ValueWithShadow MmapRegion::read8(FlatPtr offset) ValueWithShadow MmapRegion::read16(u32 offset) { if (!is_readable()) { - reportln("16-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("16-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -103,7 +103,7 @@ ValueWithShadow MmapRegion::read16(u32 offset) ValueWithShadow MmapRegion::read32(u32 offset) { if (!is_readable()) { - reportln("32-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("32-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -124,7 +124,7 @@ ValueWithShadow MmapRegion::read32(u32 offset) ValueWithShadow MmapRegion::read64(u32 offset) { if (!is_readable()) { - reportln("64-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("64-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -145,7 +145,7 @@ ValueWithShadow MmapRegion::read64(u32 offset) ValueWithShadow MmapRegion::read128(u32 offset) { if (!is_readable()) { - reportln("128-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("128-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -165,7 +165,7 @@ ValueWithShadow MmapRegion::read128(u32 offset) ValueWithShadow MmapRegion::read256(u32 offset) { if (!is_readable()) { - reportln("256-bit read from unreadable MmapRegion @ {:p}", base() + offset); + reportln("256-bit read from unreadable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -185,7 +185,7 @@ ValueWithShadow MmapRegion::read256(u32 offset) void MmapRegion::write8(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("8-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("8-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -203,7 +203,7 @@ void MmapRegion::write8(u32 offset, ValueWithShadow value) void MmapRegion::write16(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("16-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("16-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -221,7 +221,7 @@ void MmapRegion::write16(u32 offset, ValueWithShadow value) void MmapRegion::write32(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("32-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("32-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -240,7 +240,7 @@ void MmapRegion::write32(u32 offset, ValueWithShadow value) void MmapRegion::write64(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("64-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("64-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -259,7 +259,7 @@ void MmapRegion::write64(u32 offset, ValueWithShadow value) void MmapRegion::write128(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("128-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("128-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } @@ -277,7 +277,7 @@ void MmapRegion::write128(u32 offset, ValueWithShadow value) void MmapRegion::write256(u32 offset, ValueWithShadow value) { if (!is_writable()) { - reportln("256-bit write from unwritable MmapRegion @ {:p}", base() + offset); + reportln("256-bit write from unwritable MmapRegion @ {:p}"sv, base() + offset); emulator().dump_backtrace(); TODO(); } diff --git a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp index f0bd5300262..db7c9cc7ca1 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftCPU.cpp @@ -19,11 +19,11 @@ # pragma GCC optimize("O3") #endif -#define TODO_INSN() \ - do { \ - reportln("\n=={}== Unimplemented instruction: {}\n", getpid(), __FUNCTION__); \ - m_emulator.dump_backtrace(); \ - _exit(0); \ +#define TODO_INSN() \ + do { \ + reportln("\n=={}== Unimplemented instruction: {}\n"sv, getpid(), __FUNCTION__); \ + m_emulator.dump_backtrace(); \ + _exit(0); \ } while (0) #define FPU_INSTRUCTION(name) \ @@ -55,7 +55,7 @@ template ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { - reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); + reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n"sv, message); Emulator::the().dump_backtrace(); } } @@ -63,7 +63,7 @@ ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* messag ALWAYS_INLINE void SoftCPU::warn_if_flags_tainted(char const* message) const { if (m_flags_tainted) [[unlikely]] { - reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n", getpid(), message); + reportln("\n=={}== \033[31;1mConditional depends on uninitialized data\033[0m ({})\n"sv, getpid(), message); Emulator::the().dump_backtrace(); } } @@ -108,7 +108,7 @@ void SoftCPU::update_code_cache() VERIFY(region); if (!region->is_executable()) { - reportln("SoftCPU::update_code_cache: Non-executable region @ {:p}", eip()); + reportln("SoftCPU::update_code_cache: Non-executable region @ {:p}"sv, eip()); Emulator::the().dump_backtrace(); TODO(); } @@ -1388,13 +1388,13 @@ void SoftCPU::DIV_RM16(const X86::Instruction& insn) { auto divisor = insn.modrm().read16(*this, insn); if (divisor.value() == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } u32 dividend = ((u32)dx().value() << 16) | ax().value(); auto quotient = dividend / divisor.value(); if (quotient > NumericLimits::max()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } @@ -1409,13 +1409,13 @@ void SoftCPU::DIV_RM32(const X86::Instruction& insn) { auto divisor = insn.modrm().read32(*this, insn); if (divisor.value() == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } u64 dividend = ((u64)edx().value() << 32) | eax().value(); auto quotient = dividend / divisor.value(); if (quotient > NumericLimits::max()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } @@ -1430,13 +1430,13 @@ void SoftCPU::DIV_RM8(const X86::Instruction& insn) { auto divisor = insn.modrm().read8(*this, insn); if (divisor.value() == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } u16 dividend = ax().value(); auto quotient = dividend / divisor.value(); if (quotient > NumericLimits::max()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } @@ -1451,7 +1451,7 @@ void SoftCPU::ENTER32(const X86::Instruction&) { TODO_INSN(); } void SoftCPU::ESCAPE(const X86::Instruction&) { - reportln("FIXME: x87 floating-point support"); + reportln("FIXME: x87 floating-point support"sv); m_emulator.dump_backtrace(); TODO(); } @@ -1582,13 +1582,13 @@ void SoftCPU::IDIV_RM16(const X86::Instruction& insn) auto divisor_with_shadow = insn.modrm().read16(*this, insn); auto divisor = (i16)divisor_with_shadow.value(); if (divisor == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } i32 dividend = (i32)(((u32)dx().value() << 16) | (u32)ax().value()); i32 result = dividend / divisor; if (result > NumericLimits::max() || result < NumericLimits::min()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } @@ -1602,13 +1602,13 @@ void SoftCPU::IDIV_RM32(const X86::Instruction& insn) auto divisor_with_shadow = insn.modrm().read32(*this, insn); auto divisor = (i32)divisor_with_shadow.value(); if (divisor == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } i64 dividend = (i64)(((u64)edx().value() << 32) | (u64)eax().value()); i64 result = dividend / divisor; if (result > NumericLimits::max() || result < NumericLimits::min()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } @@ -1622,13 +1622,13 @@ void SoftCPU::IDIV_RM8(const X86::Instruction& insn) auto divisor_with_shadow = insn.modrm().read8(*this, insn); auto divisor = (i8)divisor_with_shadow.value(); if (divisor == 0) { - reportln("Divide by zero"); + reportln("Divide by zero"sv); TODO(); } i16 dividend = ax().value(); i16 result = dividend / divisor; if (result > NumericLimits::max() || result < NumericLimits::min()) { - reportln("Divide overflow"); + reportln("Divide overflow"sv); TODO(); } diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp index efe02f9d4a7..00eefa6aceb 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.cpp @@ -20,18 +20,18 @@ # pragma GCC optimize("O3") #endif -#define TODO_INSN() \ - do { \ - reportln("\n=={}== Unimplemented instruction: {}\n", getpid(), __FUNCTION__); \ - m_emulator.dump_backtrace(); \ - _exit(0); \ +#define TODO_INSN() \ + do { \ + reportln("\n=={}== Unimplemented instruction: {}\n"sv, getpid(), __FUNCTION__); \ + m_emulator.dump_backtrace(); \ + _exit(0); \ } while (0) template ALWAYS_INLINE void warn_if_uninitialized(T value_with_shadow, char const* message) { if (value_with_shadow.is_uninitialized()) [[unlikely]] { - reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n", message); + reportln("\033[31;1mWarning! Use of uninitialized value: {}\033[0m\n"sv, message); UserspaceEmulator::Emulator::the().dump_backtrace(); } } @@ -41,14 +41,14 @@ namespace UserspaceEmulator { // NOLINT(readability-implicit-bool-conversion) 0/ ALWAYS_INLINE void SoftFPU::warn_if_mmx_absolute(u8 index) const { if (m_reg_is_mmx[index]) [[unlikely]] { - reportln("\033[31;1mWarning! Use of an MMX register as an FPU value ({} abs)\033[0m\n", index); + reportln("\033[31;1mWarning! Use of an MMX register as an FPU value ({} abs)\033[0m\n"sv, index); m_emulator.dump_backtrace(); } } ALWAYS_INLINE void SoftFPU::warn_if_fpu_absolute(u8 index) const { if (!m_reg_is_mmx[index]) [[unlikely]] { - reportln("\033[31;1mWarning! Use of an FPU value ({} abs) as an MMX register\033[0m\n", index); + reportln("\033[31;1mWarning! Use of an FPU value ({} abs) as an MMX register\033[0m\n"sv, index); m_emulator.dump_backtrace(); } } @@ -161,7 +161,7 @@ ALWAYS_INLINE void SoftFPU::fpu_set_exception(FPU_Exception ex) // the previous eip // FIXME: Call FPU Exception handler - reportln("Trying to call Exception handler from {}", fpu_exception_string(ex)); + reportln("Trying to call Exception handler from {}"sv, fpu_exception_string(ex)); fpu_dump_env(); m_emulator.dump_backtrace(); TODO(); diff --git a/Userland/DevTools/UserspaceEmulator/SoftFPU.h b/Userland/DevTools/UserspaceEmulator/SoftFPU.h index 5e142becfb0..4d3d0f4f2c2 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftFPU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftFPU.h @@ -87,7 +87,7 @@ private: void fpu_dump_env() { - reportln("Exceptions: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{} #SF:{} Summary:{}", + reportln("Exceptions: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{} #SF:{} Summary:{}"sv, m_fpu_error_invalid, m_fpu_error_denorm, m_fpu_error_zero_div, @@ -96,18 +96,18 @@ private: m_fpu_error_precision, m_fpu_error_stackfault, m_fpu_error_summary); - reportln("Masks: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{}", + reportln("Masks: #I:{} #D:{} #Z:{} #O:{} #U:{} #P:{}"sv, m_fpu_cw.mask_invalid, m_fpu_cw.mask_denorm, m_fpu_cw.mask_zero_div, m_fpu_cw.mask_overflow, m_fpu_cw.mask_underflow, m_fpu_cw.mask_precision); - reportln("C0:{} C1:{} C2:{} C3:{}", c0(), c1(), c2(), c3()); - reportln("fpu-stacktop: {}", m_fpu_stack_top); - reportln("fpu-stack /w stacktop (real):"); + reportln("C0:{} C1:{} C2:{} C3:{}"sv, c0(), c1(), c2(), c3()); + reportln("fpu-stacktop: {}"sv, m_fpu_stack_top); + reportln("fpu-stack /w stacktop (real):"sv); for (u8 i = 0; i < 8; ++i) { - reportln("\t{} ({}): fp {} ({}), mmx {:016x}", + reportln("\t{} ({}): fp {} ({}), mmx {:016x}"sv, i, (u8)((m_fpu_stack_top + i) % 8), m_storage[(m_fpu_stack_top + i) % 8].fp, fpu_is_set(i) ? "set" : "free", m_storage[(m_fpu_stack_top + i) % 8].mmx.raw); @@ -142,14 +142,14 @@ private: ALWAYS_INLINE void fpu_set_stack_overflow() { - reportln("Stack Overflow"); + reportln("Stack Overflow"sv); set_c1(1); fpu_set_exception(FPU_Exception::StackFault); } ALWAYS_INLINE void fpu_set_stack_underflow() { - reportln("Stack Underflow"); + reportln("Stack Underflow"sv); set_c1(0); fpu_set_exception(FPU_Exception::StackFault); } diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp index ab99784cb79..d17c62b5686 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.cpp @@ -94,13 +94,13 @@ ValueWithShadow SoftMMU::read8(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read8: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read8: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read8: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read8: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -112,13 +112,13 @@ ValueWithShadow SoftMMU::read16(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read16: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read16: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read16: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read16: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -130,13 +130,13 @@ ValueWithShadow SoftMMU::read32(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read32: No region for @ {:04x}:{:p}", address.selector(), address.offset()); + reportln("SoftMMU::read32: No region for @ {:04x}:{:p}"sv, address.selector(), address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read32: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read32: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -148,13 +148,13 @@ ValueWithShadow SoftMMU::read64(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read64: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read64: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read64: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read64: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -166,13 +166,13 @@ ValueWithShadow SoftMMU::read128(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read128: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read128: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read128: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read128: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -184,13 +184,13 @@ ValueWithShadow SoftMMU::read256(X86::LogicalAddress address) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read256: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read256: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read256: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read256: Non-readable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -202,13 +202,13 @@ void SoftMMU::write8(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write8: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write8: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write8: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write8: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -219,13 +219,13 @@ void SoftMMU::write16(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write16: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write16: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write16: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write16: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -237,13 +237,13 @@ void SoftMMU::write32(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write32: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write32: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write32: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write32: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -255,13 +255,13 @@ void SoftMMU::write64(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write64: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write64: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write64: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write64: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -273,13 +273,13 @@ void SoftMMU::write128(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write128: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write128: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write128: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write128: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } @@ -291,13 +291,13 @@ void SoftMMU::write256(X86::LogicalAddress address, ValueWithShadow value) { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::write256: No region for @ {:p}", address.offset()); + reportln("SoftMMU::write256: No region for @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } if (!region->is_writable()) { - reportln("SoftMMU::write256: Non-writable region @ {:p}", address.offset()); + reportln("SoftMMU::write256: Non-writable region @ {:p}"sv, address.offset()); m_emulator.dump_backtrace(); TODO(); } diff --git a/Userland/DevTools/UserspaceEmulator/SoftMMU.h b/Userland/DevTools/UserspaceEmulator/SoftMMU.h index f36bb39bd6b..658db41eee8 100644 --- a/Userland/DevTools/UserspaceEmulator/SoftMMU.h +++ b/Userland/DevTools/UserspaceEmulator/SoftMMU.h @@ -37,13 +37,13 @@ public: { auto* region = find_region(address); if (!region) { - reportln("SoftMMU::read256: No region for @ {:p}", address.offset()); + reportln("SoftMMU::read256: No region for @ {:p}"sv, address.offset()); dump_backtrace(); TODO(); } if (!region->is_readable()) { - reportln("SoftMMU::read256: Non-readable region @ {:p}", address.offset()); + reportln("SoftMMU::read256: Non-readable region @ {:p}"sv, address.offset()); dump_backtrace(); TODO(); } diff --git a/Userland/DevTools/UserspaceEmulator/main.cpp b/Userland/DevTools/UserspaceEmulator/main.cpp index b97a2ff23a7..b661b78ef84 100644 --- a/Userland/DevTools/UserspaceEmulator/main.cpp +++ b/Userland/DevTools/UserspaceEmulator/main.cpp @@ -51,7 +51,7 @@ int main(int argc, char** argv, char** env) else executable_path = Core::find_executable_in_path(arguments[0]); if (executable_path.is_empty()) { - reportln("Cannot find executable for '{}'.", arguments[0]); + reportln("Cannot find executable for '{}'."sv, arguments[0]); return 1; } @@ -98,7 +98,7 @@ int main(int argc, char** argv, char** env) return 1; StringBuilder builder; - builder.append("(UE) "); + builder.append("(UE) "sv); builder.append(LexicalPath::basename(arguments[0])); if (set_process_name(builder.string_view().characters_without_null_termination(), builder.string_view().length()) < 0) { perror("set_process_name"); @@ -106,7 +106,7 @@ int main(int argc, char** argv, char** env) } int rc = pthread_setname_np(pthread_self(), builder.to_string().characters()); if (rc != 0) { - reportln("pthread_setname_np: {}", strerror(rc)); + reportln("pthread_setname_np: {}"sv, strerror(rc)); return 1; } diff --git a/Userland/Games/2048/main.cpp b/Userland/Games/2048/main.cpp index e42066ceb3c..89faf47377a 100644 --- a/Userland/Games/2048/main.cpp +++ b/Userland/Games/2048/main.cpp @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) srand(time(nullptr)); auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-2048")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-2048"sv)); auto window = TRY(GUI::Window::try_create()); @@ -48,18 +48,18 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - size_t board_size = Config::read_i32("2048", "", "board_size", 4); - u32 target_tile = Config::read_i32("2048", "", "target_tile", 2048); - bool evil_ai = Config::read_bool("2048", "", "evil_ai", false); + size_t board_size = Config::read_i32("2048"sv, ""sv, "board_size"sv, 4); + u32 target_tile = Config::read_i32("2048"sv, ""sv, "target_tile"sv, 2048); + bool evil_ai = Config::read_bool("2048"sv, ""sv, "evil_ai"sv, false); if ((target_tile & (target_tile - 1)) != 0) { // If the target tile is not a power of 2, reset to its default value. target_tile = 2048; } - Config::write_i32("2048", "", "board_size", board_size); - Config::write_i32("2048", "", "target_tile", target_tile); - Config::write_bool("2048", "", "evil_ai", evil_ai); + Config::write_i32("2048"sv, ""sv, "board_size"sv, board_size); + Config::write_i32("2048"sv, ""sv, "target_tile"sv, target_tile); + Config::write_bool("2048"sv, ""sv, "evil_ai"sv, evil_ai); window->set_double_buffering_enabled(false); window->set_title("2048"); @@ -108,15 +108,15 @@ ErrorOr serenity_main(Main::Arguments arguments) if (!size_dialog->temporary()) { - Config::write_i32("2048", "", "board_size", board_size); - Config::write_i32("2048", "", "target_tile", target_tile); - Config::write_bool("2048", "", "evil_ai", evil_ai); + Config::write_i32("2048"sv, ""sv, "board_size"sv, board_size); + Config::write_i32("2048"sv, ""sv, "target_tile"sv, target_tile); + Config::write_bool("2048"sv, ""sv, "evil_ai"sv, evil_ai); - GUI::MessageBox::show(window, "New settings have been saved and will be applied on a new game", "Settings Changed Successfully", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window, "New settings have been saved and will be applied on a new game"sv, "Settings Changed Successfully"sv, GUI::MessageBox::Type::Information); return; } - GUI::MessageBox::show(window, "New settings have been set and will be applied on the next game", "Settings Changed Successfully", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window, "New settings have been set and will be applied on the next game"sv, "Settings Changed Successfully"sv, GUI::MessageBox::Type::Information); }; auto start_a_new_game = [&] { // Do not leak game states between games. @@ -149,7 +149,7 @@ ErrorOr serenity_main(Main::Arguments arguments) update(); auto want_to_continue = GUI::MessageBox::show(window, String::formatted("You won the game in {} turns with a score of {}. Would you like to continue?", game.turns(), game.score()), - "Congratulations!", + "Congratulations!"sv, GUI::MessageBox::Type::Question, GUI::MessageBox::InputType::YesNo); if (want_to_continue == GUI::MessageBox::ExecResult::Yes) @@ -162,7 +162,7 @@ ErrorOr serenity_main(Main::Arguments arguments) update(); GUI::MessageBox::show(window, String::formatted("You reached {} in {} turns with a score of {}", game.largest_tile(), game.turns(), game.score()), - "You lost!", + "You lost!"sv, GUI::MessageBox::Type::Information); start_a_new_game(); break; @@ -171,7 +171,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { start_a_new_game(); }))); @@ -192,7 +192,7 @@ ErrorOr serenity_main(Main::Arguments arguments) }))); TRY(game_menu->try_add_separator()); - TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) { change_settings(); }))); diff --git a/Userland/Games/Chess/ChessWidget.cpp b/Userland/Games/Chess/ChessWidget.cpp index 3480d7ce1e9..4c3c7da53d2 100644 --- a/Userland/Games/Chess/ChessWidget.cpp +++ b/Userland/Games/Chess/ChessWidget.cpp @@ -20,7 +20,7 @@ ChessWidget::ChessWidget() { - set_piece_set("stelar7"); + set_piece_set("stelar7"sv); } void ChessWidget::paint_event(GUI::PaintEvent& event) @@ -248,46 +248,46 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) if (board().game_result() != Chess::Board::Result::NotFinished) { bool over = true; - String msg; + StringView msg; switch (board().game_result()) { case Chess::Board::Result::CheckMate: if (board().turn() == Chess::Color::White) { - msg = "Black wins by Checkmate."; + msg = "Black wins by Checkmate."sv; } else { - msg = "White wins by Checkmate."; + msg = "White wins by Checkmate."sv; } break; case Chess::Board::Result::StaleMate: - msg = "Draw by Stalemate."; + msg = "Draw by Stalemate."sv; break; case Chess::Board::Result::FiftyMoveRule: update(); - if (GUI::MessageBox::show(window(), "50 moves have elapsed without a capture. Claim Draw?", "Claim Draw?", + if (GUI::MessageBox::show(window(), "50 moves have elapsed without a capture. Claim Draw?"sv, "Claim Draw?"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) == GUI::Dialog::ExecResult::Yes) { - msg = "Draw by 50 move rule."; + msg = "Draw by 50 move rule."sv; } else { over = false; } break; case Chess::Board::Result::SeventyFiveMoveRule: - msg = "Draw by 75 move rule."; + msg = "Draw by 75 move rule."sv; break; case Chess::Board::Result::ThreeFoldRepetition: update(); - if (GUI::MessageBox::show(window(), "The same board state has repeated three times. Claim Draw?", "Claim Draw?", + if (GUI::MessageBox::show(window(), "The same board state has repeated three times. Claim Draw?"sv, "Claim Draw?"sv, GUI::MessageBox::Type::Information, GUI::MessageBox::InputType::YesNo) == GUI::Dialog::ExecResult::Yes) { - msg = "Draw by threefold repetition."; + msg = "Draw by threefold repetition."sv; } else { over = false; } break; case Chess::Board::Result::FiveFoldRepetition: - msg = "Draw by fivefold repetition."; + msg = "Draw by fivefold repetition."sv; break; case Chess::Board::Result::InsufficientMaterial: - msg = "Draw by insufficient material."; + msg = "Draw by insufficient material."sv; break; default: VERIFY_NOT_REACHED(); @@ -296,7 +296,7 @@ void ChessWidget::mouseup_event(GUI::MouseEvent& event) set_override_cursor(Gfx::StandardCursor::None); set_drag_enabled(false); update(); - GUI::MessageBox::show(window(), msg, "Game Over", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), msg, "Game Over"sv, GUI::MessageBox::Type::Information); } } else { input_engine_move(); @@ -377,18 +377,18 @@ static RefPtr get_piece(StringView set, StringView image) void ChessWidget::set_piece_set(StringView set) { m_piece_set = set; - m_pieces.set({ Chess::Color::White, Chess::Type::Pawn }, get_piece(set, "white-pawn.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::Pawn }, get_piece(set, "black-pawn.png")); - m_pieces.set({ Chess::Color::White, Chess::Type::Knight }, get_piece(set, "white-knight.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::Knight }, get_piece(set, "black-knight.png")); - m_pieces.set({ Chess::Color::White, Chess::Type::Bishop }, get_piece(set, "white-bishop.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::Bishop }, get_piece(set, "black-bishop.png")); - m_pieces.set({ Chess::Color::White, Chess::Type::Rook }, get_piece(set, "white-rook.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::Rook }, get_piece(set, "black-rook.png")); - m_pieces.set({ Chess::Color::White, Chess::Type::Queen }, get_piece(set, "white-queen.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::Queen }, get_piece(set, "black-queen.png")); - m_pieces.set({ Chess::Color::White, Chess::Type::King }, get_piece(set, "white-king.png")); - m_pieces.set({ Chess::Color::Black, Chess::Type::King }, get_piece(set, "black-king.png")); + m_pieces.set({ Chess::Color::White, Chess::Type::Pawn }, get_piece(set, "white-pawn.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::Pawn }, get_piece(set, "black-pawn.png"sv)); + m_pieces.set({ Chess::Color::White, Chess::Type::Knight }, get_piece(set, "white-knight.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::Knight }, get_piece(set, "black-knight.png"sv)); + m_pieces.set({ Chess::Color::White, Chess::Type::Bishop }, get_piece(set, "white-bishop.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::Bishop }, get_piece(set, "black-bishop.png"sv)); + m_pieces.set({ Chess::Color::White, Chess::Type::Rook }, get_piece(set, "white-rook.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::Rook }, get_piece(set, "black-rook.png"sv)); + m_pieces.set({ Chess::Color::White, Chess::Type::Queen }, get_piece(set, "white-queen.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::Queen }, get_piece(set, "black-queen.png"sv)); + m_pieces.set({ Chess::Color::White, Chess::Type::King }, get_piece(set, "white-king.png"sv)); + m_pieces.set({ Chess::Color::Black, Chess::Type::King }, get_piece(set, "black-king.png"sv)); } Chess::Square ChessWidget::mouse_to_square(GUI::MouseEvent& event) const @@ -436,7 +436,7 @@ void ChessWidget::set_board_theme(StringView name) } else if (name == "Blue") { m_board_theme = { "Blue", Color::from_rgb(0x8ca2ad), Color::from_rgb(0xdee3e6) }; } else { - set_board_theme("Beige"); + set_board_theme("Beige"sv); } } @@ -596,15 +596,15 @@ bool ChessWidget::import_pgn(StringView import_path) if (token.contains("*")) break; // FIXME: When we become able to set more of the game state, fix these end results - if (token.contains("1-0")) { + if (token.contains("1-0"sv)) { m_board.set_resigned(Chess::Color::Black); break; } - if (token.contains("0-1")) { + if (token.contains("0-1"sv)) { m_board.set_resigned(Chess::Color::White); break; } - if (token.contains("1/2-1/2")) { + if (token.contains("1/2-1/2"sv)) { break; } if (!token.ends_with(".")) { @@ -633,24 +633,24 @@ bool ChessWidget::export_pgn(StringView export_path) const auto& file = *file_or_error.value(); // Tag Pair Section - file.write("[Event \"Casual Game\"]\n"); - file.write("[Site \"SerenityOS Chess\"]\n"); - file.write(String::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"))); - file.write("[Round \"1\"]\n"); + file.write("[Event \"Casual Game\"]\n"sv); + file.write("[Site \"SerenityOS Chess\"]\n"sv); + file.write(String::formatted("[Date \"{}\"]\n", Core::DateTime::now().to_string("%Y.%m.%d"sv))); + file.write("[Round \"1\"]\n"sv); String username(getlogin()); - const String player1 = (!username.is_empty() ? username : "?"); - const String player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine" : "?"); + const String player1 = (!username.is_empty() ? username.view() : "?"sv); + const String player2 = (!m_engine.is_null() ? "SerenityOS ChessEngine"sv : "?"sv); file.write(String::formatted("[White \"{}\"]\n", m_side == Chess::Color::White ? player1 : player2)); file.write(String::formatted("[Black \"{}\"]\n", m_side == Chess::Color::Black ? player1 : player2)); file.write(String::formatted("[Result \"{}\"]\n", Chess::Board::result_to_points(m_board.game_result(), m_board.turn()))); - file.write("[WhiteElo \"?\"]\n"); - file.write("[BlackElo \"?\"]\n"); - file.write("[Variant \"Standard\"]\n"); - file.write("[TimeControl \"-\"]\n"); - file.write("[Annotator \"SerenityOS Chess\"]\n"); - file.write("\n"); + file.write("[WhiteElo \"?\"]\n"sv); + file.write("[BlackElo \"?\"]\n"sv); + file.write("[Variant \"Standard\"]\n"sv); + file.write("[TimeControl \"-\"]\n"sv); + file.write("[Annotator \"SerenityOS Chess\"]\n"sv); + file.write("\n"sv); // Movetext Section for (size_t i = 0, move_no = 1; i < m_board.moves().size(); i += 2, move_no++) { @@ -664,11 +664,11 @@ bool ChessWidget::export_pgn(StringView export_path) const } } - file.write("{ "); + file.write("{ "sv); file.write(Chess::Board::result_to_string(m_board.game_result(), m_board.turn())); - file.write(" } "); + file.write(" } "sv); file.write(Chess::Board::result_to_points(m_board.game_result(), m_board.turn())); - file.write("\n"); + file.write("\n"sv); file.close(); return true; @@ -677,7 +677,7 @@ bool ChessWidget::export_pgn(StringView export_path) const void ChessWidget::flip_board() { if (want_engine_move()) { - GUI::MessageBox::show(window(), "You can only flip the board on your turn.", "Flip Board", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), "You can only flip the board on your turn."sv, "Flip Board"sv, GUI::MessageBox::Type::Information); return; } m_side = Chess::opposing_color(m_side); @@ -688,11 +688,11 @@ void ChessWidget::flip_board() int ChessWidget::resign() { if (want_engine_move()) { - GUI::MessageBox::show(window(), "You can only resign on your turn.", "Resign", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), "You can only resign on your turn."sv, "Resign"sv, GUI::MessageBox::Type::Information); return -1; } - auto result = GUI::MessageBox::show(window(), "Are you sure you wish to resign?", "Resign", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); + auto result = GUI::MessageBox::show(window(), "Are you sure you wish to resign?"sv, "Resign"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); if (result != GUI::MessageBox::ExecResult::Yes) return -1; @@ -701,7 +701,7 @@ int ChessWidget::resign() set_drag_enabled(false); update(); const String msg = Chess::Board::result_to_string(m_board.game_result(), m_board.turn()); - GUI::MessageBox::show(window(), msg, "Game Over", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window(), msg, "Game Over"sv, GUI::MessageBox::Type::Information); return 0; } diff --git a/Userland/Games/Chess/main.cpp b/Userland/Games/Chess/main.cpp index dad764ee45e..374aa2b9b80 100644 --- a/Userland/Games/Chess/main.cpp +++ b/Userland/Games/Chess/main.cpp @@ -33,7 +33,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio rpath wpath cpath recvfd sendfd thread proc exec")); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-chess"sv)); auto window = TRY(GUI::Window::try_create()); auto widget = TRY(window->try_set_main_widget()); @@ -42,10 +42,10 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/bin/ChessEngine", "x")); TRY(Core::System::unveil("/etc/passwd", "r")); TRY(Core::System::unveil("/tmp/portal/launch", "rw")); - TRY(Core::System::unveil(Core::StandardPaths::home_directory().characters(), "wcbr")); + TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "wcbr"sv)); TRY(Core::System::unveil(nullptr, nullptr)); - auto size = Config::read_i32("Chess", "Display", "size", 512); + auto size = Config::read_i32("Chess"sv, "Display"sv, "size"sv, 512); window->set_title("Chess"); window->set_base_size({ 4, 4 }); window->set_size_increment({ 8, 8 }); @@ -53,10 +53,10 @@ ErrorOr serenity_main(Main::Arguments arguments) window->set_icon(app_icon.bitmap_for_size(16)); - widget->set_piece_set(Config::read_string("Chess", "Style", "PieceSet", "stelar7")); - widget->set_board_theme(Config::read_string("Chess", "Style", "BoardTheme", "Beige")); - widget->set_coordinates(Config::read_bool("Chess", "Style", "Coordinates", true)); - widget->set_show_available_moves(Config::read_bool("Chess", "Style", "ShowAvailableMoves", true)); + widget->set_piece_set(Config::read_string("Chess"sv, "Style"sv, "PieceSet"sv, "stelar7"sv)); + widget->set_board_theme(Config::read_string("Chess"sv, "Style"sv, "BoardTheme"sv, "Beige"sv)); + widget->set_coordinates(Config::read_bool("Chess"sv, "Style"sv, "Coordinates"sv, true)); + widget->set_show_available_moves(Config::read_bool("Chess"sv, "Style"sv, "ShowAvailableMoves"sv, true)); auto game_menu = TRY(window->try_add_menu("&Game")); @@ -75,7 +75,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; if (!widget->import_pgn(import_path.value())) { - GUI::MessageBox::show(window, "Unable to import game.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Unable to import game.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -88,7 +88,7 @@ ErrorOr serenity_main(Main::Arguments arguments) return; if (!widget->export_pgn(export_path.value())) { - GUI::MessageBox::show(window, "Unable to export game.\n", "Error", GUI::MessageBox::Type::Error); + GUI::MessageBox::show(window, "Unable to export game.\n"sv, "Error"sv, GUI::MessageBox::Type::Error); return; } @@ -96,11 +96,11 @@ ErrorOr serenity_main(Main::Arguments arguments) }))); TRY(game_menu->try_add_action(GUI::Action::create("&Copy FEN", { Mod_Ctrl, Key_C }, [&](auto&) { GUI::Clipboard::the().set_data(widget->get_fen().bytes()); - GUI::MessageBox::show(window, "Board state copied to clipboard as FEN.", "Copy FEN", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window, "Board state copied to clipboard as FEN."sv, "Copy FEN"sv, GUI::MessageBox::Type::Information); }))); TRY(game_menu->try_add_separator()); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { if (widget->board().game_result() == Chess::Board::Result::NotFinished) { if (widget->resign() < 0) return; @@ -124,7 +124,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto action = GUI::Action::create_checkable(set, [&](auto& action) { widget->set_piece_set(action.text()); widget->update(); - Config::write_string("Chess", "Style", "PieceSet", action.text()); + Config::write_string("Chess"sv, "Style"sv, "PieceSet"sv, action.text()); }); piece_set_action_group.add_action(*action); @@ -136,13 +136,13 @@ ErrorOr serenity_main(Main::Arguments arguments) GUI::ActionGroup board_theme_action_group; board_theme_action_group.set_exclusive(true); auto board_theme_menu = TRY(style_menu->try_add_submenu("Board Theme")); - board_theme_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png").release_value_but_fixme_should_propagate_errors()); + board_theme_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/chess/mini-board.png"sv).release_value_but_fixme_should_propagate_errors()); for (auto const& theme : { "Beige", "Green", "Blue" }) { auto action = GUI::Action::create_checkable(theme, [&](auto& action) { widget->set_board_theme(action.text()); widget->update(); - Config::write_string("Chess", "Style", "BoardTheme", action.text()); + Config::write_string("Chess"sv, "Style"sv, "BoardTheme"sv, action.text()); }); board_theme_action_group.add_action(*action); if (widget->board_theme().name == theme) @@ -153,7 +153,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto coordinates_action = GUI::Action::create_checkable("Coordinates", [&](auto& action) { widget->set_coordinates(action.is_checked()); widget->update(); - Config::write_bool("Chess", "Style", "Coordinates", action.is_checked()); + Config::write_bool("Chess"sv, "Style"sv, "Coordinates"sv, action.is_checked()); }); coordinates_action->set_checked(widget->coordinates()); TRY(style_menu->try_add_action(coordinates_action)); @@ -161,7 +161,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto show_available_moves_action = GUI::Action::create_checkable("Show Available Moves", [&](auto& action) { widget->set_show_available_moves(action.is_checked()); widget->update(); - Config::write_bool("Chess", "Style", "ShowAvailableMoves", action.is_checked()); + Config::write_bool("Chess"sv, "Style"sv, "ShowAvailableMoves"sv, action.is_checked()); }); show_available_moves_action->set_checked(widget->show_available_moves()); TRY(style_menu->try_add_action(show_available_moves_action)); diff --git a/Userland/Games/FlappyBug/Game.cpp b/Userland/Games/FlappyBug/Game.cpp index b494cfd204a..e8fc4946bd8 100644 --- a/Userland/Games/FlappyBug/Game.cpp +++ b/Userland/Games/FlappyBug/Game.cpp @@ -76,7 +76,7 @@ void Game::paint_event(GUI::PaintEvent& event) auto message = String::formatted("Your score: {:.0}\nHigh score: {:.0}\n\n{}", m_last_score, m_high_score.value(), m_restart_cooldown < 0 ? "Press any key to play again" : " "); painter.draw_text(m_text_rect, message, Gfx::TextAlignment::Center, Color::White); } else { - painter.draw_text(m_text_rect, "Press any key to start", Gfx::TextAlignment::Center, Color::White); + painter.draw_text(m_text_rect, "Press any key to start"sv, Gfx::TextAlignment::Center, Color::White); } } diff --git a/Userland/Games/FlappyBug/Game.h b/Userland/Games/FlappyBug/Game.h index c12a753138c..74137707b9b 100644 --- a/Userland/Games/FlappyBug/Game.h +++ b/Userland/Games/FlappyBug/Game.h @@ -59,8 +59,8 @@ public: public: static ErrorOr construct() { - NonnullRefPtr falling_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png")); - NonnullRefPtr flapping_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png")); + NonnullRefPtr falling_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/falling.png"sv)); + NonnullRefPtr flapping_bitmap = TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/flapping.png"sv)); return Bug(move(falling_bitmap), move(flapping_bitmap)); } @@ -139,9 +139,9 @@ public: static ErrorOr construct() { Vector> const cloud_bitmaps { - TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png")), - TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png")), - TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png")), + TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_0.png"sv)), + TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_1.png"sv)), + TRY(Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/cloud_2.png"sv)), }; return Cloud(move(cloud_bitmaps)); } @@ -173,7 +173,7 @@ private: float m_last_score {}; float m_difficulty {}; float m_restart_cooldown {}; - NonnullRefPtr m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png").release_value_but_fixme_should_propagate_errors() }; + NonnullRefPtr m_background_bitmap { Gfx::Bitmap::try_load_from_file("/res/icons/flappybug/background.png"sv).release_value_but_fixme_should_propagate_errors() }; const Gfx::IntRect m_score_rect { 10, 10, 20, 20 }; const Gfx::IntRect m_text_rect { game_width / 2 - 80, game_height / 2 - 40, 160, 80 }; diff --git a/Userland/Games/FlappyBug/main.cpp b/Userland/Games/FlappyBug/main.cpp index c58a1ec3e0a..91b38b18cd1 100644 --- a/Userland/Games/FlappyBug/main.cpp +++ b/Userland/Games/FlappyBug/main.cpp @@ -34,11 +34,11 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - u32 high_score = Config::read_i32("FlappyBug", "Game", "HighScore", 0); + u32 high_score = Config::read_i32("FlappyBug"sv, "Game"sv, "HighScore"sv, 0); auto window = TRY(GUI::Window::try_create()); window->resize(FlappyBug::Game::game_width, FlappyBug::Game::game_height); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-flappybug")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-flappybug"sv)); window->set_icon(app_icon.bitmap_for_size(16)); window->set_title("Flappy Bug"); window->set_double_buffering_enabled(false); @@ -49,7 +49,7 @@ ErrorOr serenity_main(Main::Arguments arguments) if (score <= high_score) return high_score; - Config::write_i32("FlappyBug", "Game", "HighScore", score); + Config::write_i32("FlappyBug"sv, "Game"sv, "HighScore"sv, score); high_score = score; return high_score; diff --git a/Userland/Games/GameOfLife/main.cpp b/Userland/Games/GameOfLife/main.cpp index e655265d9f6..45283933969 100644 --- a/Userland/Games/GameOfLife/main.cpp +++ b/Userland/Games/GameOfLife/main.cpp @@ -40,7 +40,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-gameoflife")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-gameoflife"sv)); auto window = TRY(GUI::Window::try_create()); window->set_icon(app_icon.bitmap_for_size(16)); @@ -90,8 +90,8 @@ ErrorOr serenity_main(Main::Arguments arguments) interval_spinbox.set_value(150); - auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png").release_value_but_fixme_should_propagate_errors(); - auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png").release_value_but_fixme_should_propagate_errors(); + auto paused_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/pause.png"sv).release_value_but_fixme_should_propagate_errors(); + auto play_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/play.png"sv).release_value_but_fixme_should_propagate_errors(); auto toggle_running_action = GUI::Action::create("&Toggle Running", { Mod_None, Key_Return }, *play_icon, [&](GUI::Action&) { board_widget->set_running(!board_widget->is_running()); @@ -100,27 +100,27 @@ ErrorOr serenity_main(Main::Arguments arguments) toggle_running_action->set_checkable(true); auto toggle_running_toolbar_button = TRY(main_toolbar.try_add_action(toggle_running_action)); - auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { + auto run_one_generation_action = GUI::Action::create("Run &Next Generation", { Mod_Ctrl, Key_Equal }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors(), [&](const GUI::Action&) { statusbar.set_text(click_tip); board_widget->run_generation(); }); (void)TRY(main_toolbar.try_add_action(run_one_generation_action)); - auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto clear_board_action = GUI::Action::create("&Clear board", { Mod_Ctrl, Key_N }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/delete.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { statusbar.set_text(click_tip); board_widget->clear_cells(); board_widget->update(); }); (void)TRY(main_toolbar.try_add_action(clear_board_action)); - auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto randomize_cells_action = GUI::Action::create("&Randomize board", { Mod_Ctrl, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { statusbar.set_text(click_tip); board_widget->randomize_cells(); board_widget->update(); }); (void)TRY(main_toolbar.try_add_action(randomize_cells_action)); - auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) { + auto rotate_pattern_action = GUI::Action::create("&Rotate pattern", { 0, Key_R }, Gfx::Bitmap::try_load_from_file("/res/icons/16x16/redo.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) { board_widget->selected_pattern()->rotate_clockwise(); }); rotate_pattern_action->set_enabled(false); diff --git a/Userland/Games/Hearts/Game.cpp b/Userland/Games/Hearts/Game.cpp index 83986fe52a9..b991f939152 100644 --- a/Userland/Games/Hearts/Game.cpp +++ b/Userland/Games/Hearts/Game.cpp @@ -146,9 +146,9 @@ void Game::show_score_card(bool game_over) score_dialog->resize({ 20 + score_card.width() + 15 + close_button.width(), 20 + score_card.height() }); StringBuilder title_builder; - title_builder.append("Score Card"); + title_builder.append("Score Card"sv); if (game_over) - title_builder.append(" - Game Over"); + title_builder.append(" - Game Over"sv); score_dialog->set_title(title_builder.to_string()); RefPtr close_timer; diff --git a/Userland/Games/Hearts/main.cpp b/Userland/Games/Hearts/main.cpp index b73081f1bbe..9934a5cfa4b 100644 --- a/Userland/Games/Hearts/main.cpp +++ b/Userland/Games/Hearts/main.cpp @@ -29,7 +29,7 @@ ErrorOr serenity_main(Main::Arguments arguments) { auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hearts")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-hearts"sv)); Config::pledge_domain("Hearts"); @@ -56,7 +56,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto& statusbar = *widget->find_descendant_of_type_named("statusbar"); statusbar.set_text(0, "Score: 0"); - String player_name = Config::read_string("Hearts", "", "player_name", "Gunnar"); + String player_name = Config::read_string("Hearts"sv, ""sv, "player_name"sv, "Gunnar"sv); game.on_status_change = [&](const AK::StringView& status) { statusbar.set_override_text(status); @@ -80,18 +80,18 @@ ErrorOr serenity_main(Main::Arguments arguments) player_name = settings_dialog->player_name(); - Config::write_string("Hearts", "", "player_name", player_name); + Config::write_string("Hearts"sv, ""sv, "player_name"sv, player_name); - GUI::MessageBox::show(window, "Settings have been successfully saved and will take effect in the next game.", "Settings Changed Successfully", GUI::MessageBox::Type::Information); + GUI::MessageBox::show(window, "Settings have been successfully saved and will take effect in the next game."sv, "Settings Changed Successfully"sv, GUI::MessageBox::Type::Information); }; auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { game.setup(player_name); }))); TRY(game_menu->try_add_separator()); - TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&Settings", TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/settings.png"sv)), [&](auto&) { change_settings(); }))); TRY(game_menu->try_add_separator()); diff --git a/Userland/Games/MasterWord/WordGame.cpp b/Userland/Games/MasterWord/WordGame.cpp index a067ab587d0..ca5b9e9ecca 100644 --- a/Userland/Games/MasterWord/WordGame.cpp +++ b/Userland/Games/MasterWord/WordGame.cpp @@ -21,9 +21,9 @@ WordGame::WordGame() { read_words(); - m_num_letters = Config::read_i32("MasterWord", "", "word_length", 5); - m_max_guesses = Config::read_i32("MasterWord", "", "max_guesses", 6); - m_check_guesses = Config::read_bool("MasterWord", "", "check_guesses_in_dictionary", false); + m_num_letters = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5); + m_max_guesses = Config::read_i32("MasterWord"sv, ""sv, "max_guesses"sv, 6); + m_check_guesses = Config::read_bool("MasterWord"sv, ""sv, "check_guesses_in_dictionary"sv, false); reset(); pick_font(); } @@ -36,7 +36,7 @@ void WordGame::reset() if (maybe_word.has_value()) m_current_word = maybe_word.value(); else { - GUI::MessageBox::show(window(), String::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"); + GUI::MessageBox::show(window(), String::formatted("Could not get a random {} letter word. Defaulting to 5.", m_num_letters), "MasterWord"sv); if (m_num_letters != 5) { m_num_letters = 5; reset(); @@ -90,10 +90,10 @@ void WordGame::keydown_event(GUI::KeyEvent& event) auto won = m_current_guess == m_current_word; m_current_guess = {}; if (won) { - GUI::MessageBox::show(window(), "You win!", "MasterWord"); + GUI::MessageBox::show(window(), "You win!"sv, "MasterWord"sv); reset(); } else if (m_guesses.size() == m_max_guesses) { - GUI::MessageBox::show(window(), String::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"); + GUI::MessageBox::show(window(), String::formatted("You lose!\nThe word was {}", m_current_word), "MasterWord"sv); reset(); } } else { @@ -161,7 +161,7 @@ void WordGame::read_words() m_words.clear(); auto response = Core::File::open("/res/words.txt", Core::OpenMode::ReadOnly); if (response.is_error()) { - GUI::MessageBox::show(nullptr, "Could not read /res/words.txt.\nPlease ensure this file exists and restart MasterWord.", "MasterWord"); + GUI::MessageBox::show(nullptr, "Could not read /res/words.txt.\nPlease ensure this file exists and restart MasterWord."sv, "MasterWord"sv); exit(0); } auto words_file = response.value(); diff --git a/Userland/Games/MasterWord/main.cpp b/Userland/Games/MasterWord/main.cpp index 28c3dd69783..9ee712ad4ee 100644 --- a/Userland/Games/MasterWord/main.cpp +++ b/Userland/Games/MasterWord/main.cpp @@ -36,7 +36,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-masterword")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-masterword"sv)); auto window = TRY(GUI::Window::try_create()); @@ -46,7 +46,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game = TRY(window->try_set_main_widget()); - auto use_system_theme = Config::read_bool("MasterWord", "", "use_system_theme", false); + auto use_system_theme = Config::read_bool("MasterWord"sv, ""sv, "use_system_theme"sv, false); game->set_use_system_theme(use_system_theme); auto shortest_word = game->shortest_word(); @@ -68,33 +68,33 @@ ErrorOr serenity_main(Main::Arguments arguments) auto settings_menu = TRY(window->try_add_menu("&Settings")); TRY(settings_menu->try_add_action(GUI::Action::create("Set &Word Length", [&](auto&) { - auto word_length = Config::read_i32("MasterWord", "", "word_length", 5); + auto word_length = Config::read_i32("MasterWord"sv, ""sv, "word_length"sv, 5); auto word_length_string = String::number(word_length); - if (GUI::InputBox::show(window, word_length_string, "Word length:", "MasterWord") == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) { + if (GUI::InputBox::show(window, word_length_string, "Word length:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !word_length_string.is_empty()) { auto maybe_word_length = word_length_string.template to_uint(); if (!maybe_word_length.has_value() || maybe_word_length.value() < shortest_word || maybe_word_length.value() > longest_word) { - GUI::MessageBox::show(window, String::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"); + GUI::MessageBox::show(window, String::formatted("Please enter a number between {} and {}.", shortest_word, longest_word), "MasterWord"sv); return; } word_length = maybe_word_length.value(); - Config::write_i32("MasterWord", "", "word_length", word_length); + Config::write_i32("MasterWord"sv, ""sv, "word_length"sv, word_length); game->set_word_length(word_length); window->resize(game->game_size()); } }))); TRY(settings_menu->try_add_action(GUI::Action::create("Set &Number Of Guesses", [&](auto&) { - auto max_guesses = Config::read_i32("MasterWord", "", "max_guesses", 5); + auto max_guesses = Config::read_i32("MasterWord"sv, ""sv, "max_guesses"sv, 5); auto max_guesses_string = String::number(max_guesses); - if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:", "MasterWord") == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) { + if (GUI::InputBox::show(window, max_guesses_string, "Maximum number of guesses:"sv, "MasterWord"sv) == GUI::InputBox::ExecResult::OK && !max_guesses_string.is_empty()) { auto maybe_max_guesses = max_guesses_string.template to_uint(); if (!maybe_max_guesses.has_value() || maybe_max_guesses.value() < 1 || maybe_max_guesses.value() > 20) { - GUI::MessageBox::show(window, "Please enter a number between 1 and 20.", "MasterWord"); + GUI::MessageBox::show(window, "Please enter a number between 1 and 20."sv, "MasterWord"sv); return; } max_guesses = maybe_max_guesses.value(); - Config::write_i32("MasterWord", "", "max_guesses", max_guesses); + Config::write_i32("MasterWord"sv, ""sv, "max_guesses"sv, max_guesses); game->set_max_guesses(max_guesses); window->resize(game->game_size()); } @@ -103,7 +103,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto toggle_check_guesses = GUI::Action::create_checkable("Check &Guesses in dictionary", [&](auto& action) { auto checked = action.is_checked(); game->set_check_guesses_in_dictionary(checked); - Config::write_bool("MasterWord", "", "check_guesses_in_dictionary", checked); + Config::write_bool("MasterWord"sv, ""sv, "check_guesses_in_dictionary"sv, checked); }); toggle_check_guesses->set_checked(game->is_checking_guesses()); TRY(settings_menu->try_add_action(toggle_check_guesses)); @@ -111,7 +111,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto theme_menu = TRY(window->try_add_menu("&Theme")); auto system_theme_action = GUI::Action::create("&System", [&](auto&) { game->set_use_system_theme(true); - Config::write_bool("MasterWord", "", "use_system_theme", true); + Config::write_bool("MasterWord"sv, ""sv, "use_system_theme"sv, true); }); system_theme_action->set_checkable(true); system_theme_action->set_checked(use_system_theme); @@ -119,7 +119,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto wordle_theme_action = GUI::Action::create("&Wordle", [&](auto&) { game->set_use_system_theme(false); - Config::write_bool("MasterWord", "", "use_system_theme", false); + Config::write_bool("MasterWord"sv, ""sv, "use_system_theme"sv, false); }); wordle_theme_action->set_checkable(true); wordle_theme_action->set_checked(!use_system_theme); diff --git a/Userland/Games/Minesweeper/Field.cpp b/Userland/Games/Minesweeper/Field.cpp index df88e1e0a38..ba2b94e193c 100644 --- a/Userland/Games/Minesweeper/Field.cpp +++ b/Userland/Games/Minesweeper/Field.cpp @@ -118,13 +118,13 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b m_time_label.set_text(String::formatted("{}.{}", m_time_elapsed / 10, m_time_elapsed % 10)); }; m_timer->set_interval(100); - m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png").release_value_but_fixme_should_propagate_errors(); - m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors(); - m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png").release_value_but_fixme_should_propagate_errors(); - m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png").release_value_but_fixme_should_propagate_errors(); - m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png").release_value_but_fixme_should_propagate_errors(); - m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png").release_value_but_fixme_should_propagate_errors(); - m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png").release_value_but_fixme_should_propagate_errors(); + m_mine_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/mine.png"sv).release_value_but_fixme_should_propagate_errors(); + m_flag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"sv).release_value_but_fixme_should_propagate_errors(); + m_badflag_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/badflag.png"sv).release_value_but_fixme_should_propagate_errors(); + m_consider_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/consider.png"sv).release_value_but_fixme_should_propagate_errors(); + m_default_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-default.png"sv).release_value_but_fixme_should_propagate_errors(); + m_good_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-good.png"sv).release_value_but_fixme_should_propagate_errors(); + m_bad_face_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/face-bad.png"sv).release_value_but_fixme_should_propagate_errors(); for (int i = 0; i < 8; ++i) m_number_bitmap[i] = Gfx::Bitmap::try_load_from_file(String::formatted("/res/icons/minesweeper/{}.png", i + 1)).release_value_but_fixme_should_propagate_errors(); // Square with mine will be filled with background color later, i.e. red @@ -137,11 +137,11 @@ Field::Field(GUI::Label& flag_label, GUI::Label& time_label, GUI::Button& face_b set_face(Face::Default); { - bool single_chording = Config::read_bool("Minesweeper", "Game", "SingleChording", false); - int mine_count = Config::read_i32("Minesweeper", "Game", "MineCount", 10); - int rows = Config::read_i32("Minesweeper", "Game", "Rows", 9); - int columns = Config::read_i32("Minesweeper", "Game", "Columns", 9); - auto difficulty_string = Config::read_string("Minesweeper", "Game", "Difficulty", "beginner"); + bool single_chording = Config::read_bool("Minesweeper"sv, "Game"sv, "SingleChording"sv, false); + int mine_count = Config::read_i32("Minesweeper"sv, "Game"sv, "MineCount"sv, 10); + int rows = Config::read_i32("Minesweeper"sv, "Game"sv, "Rows"sv, 9); + int columns = Config::read_i32("Minesweeper"sv, "Game"sv, "Columns"sv, 9); + auto difficulty_string = Config::read_string("Minesweeper"sv, "Game"sv, "Difficulty"sv, "beginner"sv); auto difficulty = difficulty_from_string(difficulty_string); // Do a quick sanity check to make sure the user hasn't tried anything crazy @@ -507,10 +507,10 @@ void Field::set_field_size(Difficulty difficulty, size_t rows, size_t columns, s if (m_rows == rows && m_columns == columns && m_mine_count == mine_count) return; { - Config::write_i32("Minesweeper", "Game", "MineCount", mine_count); - Config::write_i32("Minesweeper", "Game", "Rows", rows); - Config::write_i32("Minesweeper", "Game", "Columns", columns); - Config::write_string("Minesweeper", "Game", "Difficulty", difficulty_to_string(difficulty)); + Config::write_i32("Minesweeper"sv, "Game"sv, "MineCount"sv, mine_count); + Config::write_i32("Minesweeper"sv, "Game"sv, "Rows"sv, rows); + Config::write_i32("Minesweeper"sv, "Game"sv, "Columns"sv, columns); + Config::write_string("Minesweeper"sv, "Game"sv, "Difficulty"sv, difficulty_to_string(difficulty)); } m_difficulty = difficulty; m_rows = rows; @@ -524,7 +524,7 @@ void Field::set_field_size(Difficulty difficulty, size_t rows, size_t columns, s void Field::set_single_chording(bool enabled) { m_single_chording = enabled; - Config::write_bool("Minesweeper", "Game", "SingleChording", m_single_chording); + Config::write_bool("Minesweeper"sv, "Game"sv, "SingleChording"sv, m_single_chording); } template diff --git a/Userland/Games/Minesweeper/Field.h b/Userland/Games/Minesweeper/Field.h index b4d986d42fc..13efd998a54 100644 --- a/Userland/Games/Minesweeper/Field.h +++ b/Userland/Games/Minesweeper/Field.h @@ -74,19 +74,19 @@ public: Optional difficulty_from_string(StringView difficulty_string) const { - if (difficulty_string.matches("beginner")) + if (difficulty_string.matches("beginner"sv)) return Difficulty::Beginner; - if (difficulty_string.equals_ignoring_case("intermediate")) + if (difficulty_string.equals_ignoring_case("intermediate"sv)) return Difficulty::Intermediate; - if (difficulty_string.equals_ignoring_case("expert")) + if (difficulty_string.equals_ignoring_case("expert"sv)) return Difficulty::Expert; - if (difficulty_string.equals_ignoring_case("madwoman")) + if (difficulty_string.equals_ignoring_case("madwoman"sv)) return Difficulty::Madwoman; - if (difficulty_string.equals_ignoring_case("custom")) + if (difficulty_string.equals_ignoring_case("custom"sv)) return Difficulty::Custom; return {}; diff --git a/Userland/Games/Minesweeper/main.cpp b/Userland/Games/Minesweeper/main.cpp index 78e786eddfd..24230702399 100644 --- a/Userland/Games/Minesweeper/main.cpp +++ b/Userland/Games/Minesweeper/main.cpp @@ -41,7 +41,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-minesweeper")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-minesweeper"sv)); auto window = TRY(GUI::Window::try_create()); window->set_resizable(false); @@ -63,7 +63,7 @@ ErrorOr serenity_main(Main::Arguments arguments) container->layout()->add_spacer(); auto flag_image = TRY(container->try_add()); - flag_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png").release_value_but_fixme_should_propagate_errors()); + flag_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/flag.png"sv).release_value_but_fixme_should_propagate_errors()); flag_image->set_fixed_width(16); auto flag_label = TRY(container->try_add()); @@ -81,7 +81,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto time_image = TRY(container->try_add()); time_image->set_fixed_width(16); - time_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png").release_value_but_fixme_should_propagate_errors()); + time_image->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/minesweeper/timer.png"sv).release_value_but_fixme_should_propagate_errors()); auto time_label = TRY(container->try_add()); time_label->set_fixed_width(50); @@ -96,7 +96,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { field->reset(); }))); diff --git a/Userland/Games/Snake/SnakeGame.cpp b/Userland/Games/Snake/SnakeGame.cpp index 27887985e87..63f187938cf 100644 --- a/Userland/Games/Snake/SnakeGame.cpp +++ b/Userland/Games/Snake/SnakeGame.cpp @@ -17,13 +17,13 @@ SnakeGame::SnakeGame() { set_font(Gfx::FontDatabase::default_fixed_width_font().bold_variant()); - m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/paprika.png").release_value_but_fixme_should_propagate_errors()); - m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/eggplant.png").release_value_but_fixme_should_propagate_errors()); - m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/cauliflower.png").release_value_but_fixme_should_propagate_errors()); - m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/tomato.png").release_value_but_fixme_should_propagate_errors()); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/paprika.png"sv).release_value_but_fixme_should_propagate_errors()); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/eggplant.png"sv).release_value_but_fixme_should_propagate_errors()); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/cauliflower.png"sv).release_value_but_fixme_should_propagate_errors()); + m_fruit_bitmaps.append(*Gfx::Bitmap::try_load_from_file("/res/icons/snake/tomato.png"sv).release_value_but_fixme_should_propagate_errors()); reset(); - m_high_score = Config::read_i32("Snake", "Snake", "HighScore", 0); + m_high_score = Config::read_i32("Snake"sv, "Snake"sv, "HighScore"sv, 0); m_high_score_text = String::formatted("Best: {}", m_high_score); } @@ -126,7 +126,7 @@ void SnakeGame::timer_event(Core::TimerEvent&) m_high_score = m_score; m_high_score_text = String::formatted("Best: {}", m_high_score); update(high_score_rect()); - Config::write_i32("Snake", "Snake", "HighScore", m_high_score); + Config::write_i32("Snake"sv, "Snake"sv, "HighScore"sv, m_high_score); } update(score_rect()); dirty_cells.append(m_fruit); diff --git a/Userland/Games/Snake/main.cpp b/Userland/Games/Snake/main.cpp index fdd30078ab3..259583f4af8 100644 --- a/Userland/Games/Snake/main.cpp +++ b/Userland/Games/Snake/main.cpp @@ -37,7 +37,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::unveil("/tmp/portal/launch", "rw")); TRY(Core::System::unveil(nullptr, nullptr)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-snake")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-snake"sv)); auto window = TRY(GUI::Window::try_create()); @@ -49,7 +49,7 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { game->reset(); }))); TRY(game_menu->try_add_separator()); diff --git a/Userland/Games/Solitaire/main.cpp b/Userland/Games/Solitaire/main.cpp index 663869ee8b4..47719acb883 100644 --- a/Userland/Games/Solitaire/main.cpp +++ b/Userland/Games/Solitaire/main.cpp @@ -27,7 +27,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath unix")); auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-solitaire")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-solitaire"sv)); Config::pledge_domain("Solitaire"); @@ -39,19 +39,19 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::Window::try_create()); window->set_title("Solitaire"); - auto mode = static_cast(Config::read_i32("Solitaire", "Settings", "Mode", static_cast(Solitaire::Mode::SingleCardDraw))); + auto mode = static_cast(Config::read_i32("Solitaire"sv, "Settings"sv, "Mode"sv, static_cast(Solitaire::Mode::SingleCardDraw))); auto update_mode = [&](Solitaire::Mode new_mode) { mode = new_mode; - Config::write_i32("Solitaire", "Settings", "Mode", static_cast(mode)); + Config::write_i32("Solitaire"sv, "Settings"sv, "Mode"sv, static_cast(mode)); }; auto high_score = [&]() { switch (mode) { case Solitaire::Mode::SingleCardDraw: - return static_cast(Config::read_i32("Solitaire", "HighScores", "SingleCardDraw", 0)); + return static_cast(Config::read_i32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, 0)); case Solitaire::Mode::ThreeCardDraw: - return static_cast(Config::read_i32("Solitaire", "HighScores", "ThreeCardDraw", 0)); + return static_cast(Config::read_i32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, 0)); default: VERIFY_NOT_REACHED(); } @@ -60,10 +60,10 @@ ErrorOr serenity_main(Main::Arguments arguments) auto update_high_score = [&](u32 new_high_score) { switch (mode) { case Solitaire::Mode::SingleCardDraw: - Config::write_i32("Solitaire", "HighScores", "SingleCardDraw", static_cast(new_high_score)); + Config::write_i32("Solitaire"sv, "HighScores"sv, "SingleCardDraw"sv, static_cast(new_high_score)); break; case Solitaire::Mode::ThreeCardDraw: - Config::write_i32("Solitaire", "HighScores", "ThreeCardDraw", static_cast(new_high_score)); + Config::write_i32("Solitaire"sv, "HighScores"sv, "ThreeCardDraw"sv, static_cast(new_high_score)); break; default: VERIFY_NOT_REACHED(); @@ -139,8 +139,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game_in_progress = timer->is_active(); if (game_in_progress) { auto result = GUI::MessageBox::show(window, - "A game is still in progress, are you sure you would like to quit?", - "Game in progress", + "A game is still in progress, are you sure you would like to quit?"sv, + "Game in progress"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); @@ -174,18 +174,18 @@ ErrorOr serenity_main(Main::Arguments arguments) three_card_draw_action->set_status_tip("Draw three cards at a time"); draw_setting_actions.add_action(three_card_draw_action); - game.set_auto_collect(Config::read_bool("Solitaire", "Settings", "AutoCollect", false)); + game.set_auto_collect(Config::read_bool("Solitaire"sv, "Settings"sv, "AutoCollect"sv, false)); auto toggle_auto_collect_action = GUI::Action::create_checkable("Auto-&Collect", [&](auto& action) { auto checked = action.is_checked(); game.set_auto_collect(checked); - Config::write_bool("Solitaire", "Settings", "AutoCollect", checked); + Config::write_bool("Solitaire"sv, "Settings"sv, "AutoCollect"sv, checked); }); toggle_auto_collect_action->set_checked(game.is_auto_collecting()); toggle_auto_collect_action->set_status_tip("Auto-collect to foundation piles"); auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { game.setup(mode); }))); TRY(game_menu->try_add_separator()); diff --git a/Userland/Games/Spider/main.cpp b/Userland/Games/Spider/main.cpp index 00db82211f7..86b346c406f 100644 --- a/Userland/Games/Spider/main.cpp +++ b/Userland/Games/Spider/main.cpp @@ -42,7 +42,7 @@ ErrorOr serenity_main(Main::Arguments arguments) TRY(Core::System::pledge("stdio recvfd sendfd rpath unix")); auto app = TRY(GUI::Application::try_create(arguments)); - auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-spider")); + auto app_icon = TRY(GUI::Icon::try_create_default_icon("app-spider"sv)); Config::pledge_domain("Spider"); @@ -54,58 +54,58 @@ ErrorOr serenity_main(Main::Arguments arguments) auto window = TRY(GUI::Window::try_create()); window->set_title("Spider"); - auto mode = static_cast(Config::read_i32("Spider", "Settings", "Mode", static_cast(Spider::Mode::SingleSuit))); + auto mode = static_cast(Config::read_i32("Spider"sv, "Settings"sv, "Mode"sv, static_cast(Spider::Mode::SingleSuit))); auto update_mode = [&](Spider::Mode new_mode) { mode = new_mode; - Config::write_i32("Spider", "Settings", "Mode", static_cast(mode)); + Config::write_i32("Spider"sv, "Settings"sv, "Mode"sv, static_cast(mode)); }; auto mode_id = [&]() { switch (mode) { case Spider::Mode::SingleSuit: - return "SingleSuit"; + return "SingleSuit"sv; case Spider::Mode::TwoSuit: - return "TwoSuit"; + return "TwoSuit"sv; default: VERIFY_NOT_REACHED(); } }; - auto statistic_display = static_cast(Config::read_i32("Spider", "Settings", "StatisticDisplay", static_cast(StatisticDisplay::HighScore))); + auto statistic_display = static_cast(Config::read_i32("Spider"sv, "Settings"sv, "StatisticDisplay"sv, static_cast(StatisticDisplay::HighScore))); auto update_statistic_display = [&](StatisticDisplay new_statistic_display) { statistic_display = new_statistic_display; - Config::write_i32("Spider", "Settings", "StatisticDisplay", static_cast(statistic_display)); + Config::write_i32("Spider"sv, "Settings"sv, "StatisticDisplay"sv, static_cast(statistic_display)); }; auto high_score = [&]() { - return static_cast(Config::read_i32("Spider", "HighScores", mode_id(), 0)); + return static_cast(Config::read_i32("Spider"sv, "HighScores"sv, mode_id(), 0)); }; auto update_high_score = [&](u32 new_high_score) { - Config::write_i32("Spider", "HighScores", mode_id(), static_cast(new_high_score)); + Config::write_i32("Spider"sv, "HighScores"sv, mode_id(), static_cast(new_high_score)); }; auto best_time = [&]() { - return static_cast(Config::read_i32("Spider", "BestTimes", mode_id(), 0)); + return static_cast(Config::read_i32("Spider"sv, "BestTimes"sv, mode_id(), 0)); }; auto update_best_time = [&](u32 new_best_time) { - Config::write_i32("Spider", "BestTimes", mode_id(), static_cast(new_best_time)); + Config::write_i32("Spider"sv, "BestTimes"sv, mode_id(), static_cast(new_best_time)); }; auto total_wins = [&]() { - return static_cast(Config::read_i32("Spider", "TotalWins", mode_id(), 0)); + return static_cast(Config::read_i32("Spider"sv, "TotalWins"sv, mode_id(), 0)); }; auto increment_total_wins = [&]() { - Config::write_i32("Spider", "TotalWins", mode_id(), static_cast(total_wins() + 1)); + Config::write_i32("Spider"sv, "TotalWins"sv, mode_id(), static_cast(total_wins() + 1)); }; auto total_losses = [&]() { - return static_cast(Config::read_i32("Spider", "TotalLosses", mode_id(), 0)); + return static_cast(Config::read_i32("Spider"sv, "TotalLosses"sv, mode_id(), 0)); }; auto increment_total_losses = [&]() { - Config::write_i32("Spider", "TotalLosses", mode_id(), static_cast(total_losses() + 1)); + Config::write_i32("Spider"sv, "TotalLosses"sv, mode_id(), static_cast(total_losses() + 1)); }; if (mode >= Spider::Mode::__Count) @@ -196,8 +196,8 @@ ErrorOr serenity_main(Main::Arguments arguments) auto game_in_progress = timer->is_active(); if (game_in_progress) { auto result = GUI::MessageBox::show(window, - "A game is still in progress, are you sure you would like to quit? Doing so will count as a loss.", - "Game in progress", + "A game is still in progress, are you sure you would like to quit? Doing so will count as a loss."sv, + "Game in progress"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo); @@ -233,7 +233,7 @@ ErrorOr serenity_main(Main::Arguments arguments) suit_actions.add_action(two_suit_action); auto game_menu = TRY(window->try_add_menu("&Game")); - TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png")), [&](auto&) { + TRY(game_menu->try_add_action(GUI::Action::create("&New Game", { Mod_None, Key_F2 }, TRY(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/reload.png"sv)), [&](auto&) { game.setup(mode); }))); TRY(game_menu->try_add_separator()); diff --git a/Userland/Libraries/LibArchive/Tar.h b/Userland/Libraries/LibArchive/Tar.h index dcfb38f9eca..6c677d79c87 100644 --- a/Userland/Libraries/LibArchive/Tar.h +++ b/Userland/Libraries/LibArchive/Tar.h @@ -43,12 +43,12 @@ enum class TarFileType : char { }; constexpr size_t block_size = 512; -constexpr StringView gnu_magic = "ustar "; // gnu format magic -constexpr StringView gnu_version = " "; // gnu format version -constexpr StringView ustar_magic = "ustar"; // ustar format magic -constexpr StringView ustar_version = "00"; // ustar format version -constexpr StringView posix1_tar_magic = ""; // POSIX.1-1988 format magic -constexpr StringView posix1_tar_version = ""; // POSIX.1-1988 format version +constexpr StringView gnu_magic = "ustar "sv; // gnu format magic +constexpr StringView gnu_version = " "sv; // gnu format version +constexpr StringView ustar_magic = "ustar"sv; // ustar format magic +constexpr StringView ustar_version = "00"sv; // ustar format version +constexpr StringView posix1_tar_magic = ""sv; // POSIX.1-1988 format magic +constexpr StringView posix1_tar_version = ""sv; // POSIX.1-1988 format version template static size_t get_field_as_integral(char const (&field)[N]) diff --git a/Userland/Libraries/LibAudio/Loader.h b/Userland/Libraries/LibAudio/Loader.h index 4f08aa91207..beacfc31c63 100644 --- a/Userland/Libraries/LibAudio/Loader.h +++ b/Userland/Libraries/LibAudio/Loader.h @@ -22,7 +22,7 @@ namespace Audio { -static constexpr StringView no_plugin_error = "No loader plugin available"; +static constexpr StringView no_plugin_error = "No loader plugin available"sv; using LoaderSamples = Result, LoaderError>; using MaybeLoaderError = Result; diff --git a/Userland/Libraries/LibAudio/Sample.h b/Userland/Libraries/LibAudio/Sample.h index 91ff28f909c..2c55336dc68 100644 --- a/Userland/Libraries/LibAudio/Sample.h +++ b/Userland/Libraries/LibAudio/Sample.h @@ -154,7 +154,7 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Audio::Sample const& value) { - return Formatter::format(builder, "[{}, {}]", value.left, value.right); + return Formatter::format(builder, "[{}, {}]"sv, value.left, value.right); } }; diff --git a/Userland/Libraries/LibC/getopt.cpp b/Userland/Libraries/LibC/getopt.cpp index 1f46fede942..3c6b346e6ce 100644 --- a/Userland/Libraries/LibC/getopt.cpp +++ b/Userland/Libraries/LibC/getopt.cpp @@ -116,7 +116,7 @@ int OptionParser::getopt() m_consumed_args = 0; } else { // Alright, so we have an option on our hands! - bool is_long_option = arg.starts_with("--"); + bool is_long_option = arg.starts_with("--"sv); if (is_long_option) res = handle_long_option(); else @@ -146,7 +146,7 @@ bool OptionParser::lookup_short_option(char option, int& needs_value) const return false; } - if (parts[1].starts_with("::")) { + if (parts[1].starts_with("::"sv)) { // If an option is followed by two colons, it optionally accepts an // argument. needs_value = optional_argument; diff --git a/Userland/Libraries/LibC/netdb.cpp b/Userland/Libraries/LibC/netdb.cpp index 6288d468413..cbee348cdee 100644 --- a/Userland/Libraries/LibC/netdb.cpp +++ b/Userland/Libraries/LibC/netdb.cpp @@ -451,7 +451,7 @@ void endservent() static bool fill_getserv_buffers(char const* line, ssize_t read) { // Splitting the line by tab delimiter and filling the servent buffers name, port, and protocol members. - auto split_line = StringView(line, read).replace(" ", "\t", ReplaceMode::All).split('\t'); + auto split_line = StringView(line, read).replace(" "sv, "\t"sv, ReplaceMode::All).split('\t'); // This indicates an incorrect file format. // Services file entries should always at least contain @@ -474,7 +474,7 @@ static bool fill_getserv_buffers(char const* line, ssize_t read) __getserv_port_buffer = number.value(); // Remove any annoying whitespace at the end of the protocol. - __getserv_protocol_buffer = port_protocol_split[1].replace(" ", "", ReplaceMode::All).replace("\t", "", ReplaceMode::All).replace("\n", "", ReplaceMode::All); + __getserv_protocol_buffer = port_protocol_split[1].replace(" "sv, ""sv, ReplaceMode::All).replace("\t"sv, ""sv, ReplaceMode::All).replace("\n"sv, ""sv, ReplaceMode::All); __getserv_alias_list_buffer.clear(); // If there are aliases for the service, we will fill the alias list buffer. @@ -630,7 +630,7 @@ void endprotoent() static bool fill_getproto_buffers(char const* line, ssize_t read) { String string_line = String(line, read); - auto split_line = string_line.replace(" ", "\t", ReplaceMode::All).split('\t'); + auto split_line = string_line.replace(" "sv, "\t"sv, ReplaceMode::All).split('\t'); // This indicates an incorrect file format. Protocols file entries should // always have at least a name and a protocol. diff --git a/Userland/Libraries/LibC/scanf.cpp b/Userland/Libraries/LibC/scanf.cpp index d82c5d6b945..fa2e21fb301 100644 --- a/Userland/Libraries/LibC/scanf.cpp +++ b/Userland/Libraries/LibC/scanf.cpp @@ -297,7 +297,7 @@ struct ReadElement { template<> struct ReadElement { ReadElement(StringView scan_set = {}, bool invert = false) - : scan_set(scan_set.is_null() ? " \t\n\f\r" : scan_set) + : scan_set(scan_set.is_null() ? " \t\n\f\r"sv : scan_set) , invert(scan_set.is_null() ? true : invert) , was_null(scan_set.is_null()) { diff --git a/Userland/Libraries/LibC/shadow.cpp b/Userland/Libraries/LibC/shadow.cpp index a7504ec3d97..099fca4cae2 100644 --- a/Userland/Libraries/LibC/shadow.cpp +++ b/Userland/Libraries/LibC/shadow.cpp @@ -87,7 +87,7 @@ static bool parse_shadow_entry(String const& line) } if (min_string.is_empty()) - min_string = "-1"; + min_string = "-1"sv; auto min_value = min_string.to_int(); if (!min_value.has_value()) { dbgln("getspent(): Malformed min value on line {}", s_line_number); @@ -95,7 +95,7 @@ static bool parse_shadow_entry(String const& line) } if (max_string.is_empty()) - max_string = "-1"; + max_string = "-1"sv; auto max_value = max_string.to_int(); if (!max_value.has_value()) { dbgln("getspent(): Malformed max value on line {}", s_line_number); @@ -103,7 +103,7 @@ static bool parse_shadow_entry(String const& line) } if (warn_string.is_empty()) - warn_string = "-1"; + warn_string = "-1"sv; auto warn = warn_string.to_int(); if (!warn.has_value()) { dbgln("getspent(): Malformed warn on line {}", s_line_number); @@ -111,7 +111,7 @@ static bool parse_shadow_entry(String const& line) } if (inact_string.is_empty()) - inact_string = "-1"; + inact_string = "-1"sv; auto inact = inact_string.to_int(); if (!inact.has_value()) { dbgln("getspent(): Malformed inact on line {}", s_line_number); @@ -119,7 +119,7 @@ static bool parse_shadow_entry(String const& line) } if (expire_string.is_empty()) - expire_string = "-1"; + expire_string = "-1"sv; auto expire = expire_string.to_int(); if (!expire.has_value()) { dbgln("getspent(): Malformed expire on line {}", s_line_number); @@ -127,7 +127,7 @@ static bool parse_shadow_entry(String const& line) } if (flag_string.is_empty()) - flag_string = "0"; + flag_string = "0"sv; auto flag = flag_string.to_int(); if (!flag.has_value()) { dbgln("getspent(): Malformed flag on line {}", s_line_number); diff --git a/Userland/Libraries/LibC/time.cpp b/Userland/Libraries/LibC/time.cpp index 8cbc57220af..163c75fa4c7 100644 --- a/Userland/Libraries/LibC/time.cpp +++ b/Userland/Libraries/LibC/time.cpp @@ -283,7 +283,7 @@ size_t strftime(char* destination, size_t max_size, char const* format, const st builder.append('\n'); break; case 'p': - builder.append(tm->tm_hour < 12 ? "AM" : "PM"); + builder.append(tm->tm_hour < 12 ? "AM"sv : "PM"sv); break; case 'r': { int display_hour = tm->tm_hour % 12; diff --git a/Userland/Libraries/LibCards/Card.cpp b/Userland/Libraries/LibCards/Card.cpp index aa4ae10d1b9..25c0ff35566 100644 --- a/Userland/Libraries/LibCards/Card.cpp +++ b/Userland/Libraries/LibCards/Card.cpp @@ -21,7 +21,7 @@ static constexpr Gfx::CharacterBitmap s_diamond { " ####### " " ##### " " ### " - " # ", + " # "sv, 9, 9 }; @@ -34,7 +34,7 @@ static constexpr Gfx::CharacterBitmap s_heart { " ####### " " ##### " " ### " - " # ", + " # "sv, 9, 9 }; @@ -47,7 +47,7 @@ static constexpr Gfx::CharacterBitmap s_spade { "#########" " ## # ## " " ### " - " ### ", + " ### "sv, 9, 9 }; @@ -60,7 +60,7 @@ static constexpr Gfx::CharacterBitmap s_club { "###########" "#### # ####" " ## ### ## " - " ### ", + " ### "sv, 11, 9 }; @@ -80,7 +80,7 @@ Card::Card(Suit suit, uint8_t value) s_background = Gfx::Bitmap::try_create(Gfx::BitmapFormat::BGRA8888, { width, height }).release_value_but_fixme_should_propagate_errors(); Gfx::Painter bg_painter(*s_background); - auto image = Gfx::Bitmap::try_load_from_file("/res/icons/cards/buggie-deck.png").release_value_but_fixme_should_propagate_errors(); + auto image = Gfx::Bitmap::try_load_from_file("/res/icons/cards/buggie-deck.png"sv).release_value_but_fixme_should_propagate_errors(); float aspect_ratio = image->width() / static_cast(image->height()); auto target_size = Gfx::IntSize(static_cast(aspect_ratio * (height - 5)), height - 5); @@ -107,7 +107,7 @@ Card::Card(Suit suit, uint8_t value) paint_rect.set_height(paint_rect.height() / 2); paint_rect.shrink(10, 6); - auto text_rect = Gfx::IntRect { 4, 6, font.width("10"), font.glyph_height() }; + auto text_rect = Gfx::IntRect { 4, 6, font.width("10"sv), font.glyph_height() }; painter.draw_text(text_rect, label, font, Gfx::TextAlignment::Center, color()); auto const& symbol = [&]() -> Gfx::CharacterBitmap const& { diff --git a/Userland/Libraries/LibCards/Card.h b/Userland/Libraries/LibCards/Card.h index 257751f0573..6577ed3c1eb 100644 --- a/Userland/Libraries/LibCards/Card.h +++ b/Userland/Libraries/LibCards/Card.h @@ -26,7 +26,7 @@ public: static constexpr int card_count = 13; static constexpr int card_radius = 5; static constexpr Array labels = { - "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" + "A"sv, "2"sv, "3"sv, "4"sv, "5"sv, "6"sv, "7"sv, "8"sv, "9"sv, "10"sv, "J"sv, "Q"sv, "K"sv }; enum class Suit { @@ -104,6 +104,6 @@ struct AK::Formatter : Formatter { VERIFY_NOT_REACHED(); } - return Formatter::format(builder, "{:>2}{}", Cards::Card::labels[card.value()], suit); + return Formatter::format(builder, "{:>2}{}"sv, Cards::Card::labels[card.value()], suit); } }; diff --git a/Userland/Libraries/LibCards/CardStack.h b/Userland/Libraries/LibCards/CardStack.h index 7c763daae3d..52356fe40d3 100644 --- a/Userland/Libraries/LibCards/CardStack.h +++ b/Userland/Libraries/LibCards/CardStack.h @@ -130,6 +130,6 @@ struct AK::Formatter : Formatter { first_card = false; } - return Formatter::format(builder, "{:<10} {:>16}: {}", type, stack.bounding_box(), cards.build()); + return Formatter::format(builder, "{:<10} {:>16}: {}"sv, type, stack.bounding_box(), cards.build()); } }; diff --git a/Userland/Libraries/LibChess/Chess.cpp b/Userland/Libraries/LibChess/Chess.cpp index 60c1ff4d884..c58c69301cc 100644 --- a/Userland/Libraries/LibChess/Chess.cpp +++ b/Userland/Libraries/LibChess/Chess.cpp @@ -88,7 +88,7 @@ String Square::to_algebraic() const Move::Move(StringView long_algebraic) : from(long_algebraic.substring_view(0, 2)) , to(long_algebraic.substring_view(2, 2)) - , promote_to(piece_for_char_promotion((long_algebraic.length() >= 5) ? long_algebraic.substring_view(4, 1) : "")) + , promote_to(piece_for_char_promotion((long_algebraic.length() >= 5) ? long_algebraic.substring_view(4, 1) : ""sv)) { } @@ -292,13 +292,13 @@ String Board::to_fen() const // 2. Active color VERIFY(m_turn != Color::None); - builder.append(m_turn == Color::White ? " w " : " b "); + builder.append(m_turn == Color::White ? " w "sv : " b "sv); // 3. Castling availability - builder.append(m_white_can_castle_kingside ? "K" : ""); - builder.append(m_white_can_castle_queenside ? "Q" : ""); - builder.append(m_black_can_castle_kingside ? "k" : ""); - builder.append(m_black_can_castle_queenside ? "q" : ""); + builder.append(m_white_can_castle_kingside ? "K"sv : ""sv); + builder.append(m_white_can_castle_queenside ? "Q"sv : ""sv); + builder.append(m_black_can_castle_kingside ? "k"sv : ""sv); + builder.append(m_black_can_castle_queenside ? "q"sv : ""sv); builder.append(" "); // 4. En passant target square diff --git a/Userland/Libraries/LibChess/UCICommand.cpp b/Userland/Libraries/LibChess/UCICommand.cpp index 91e0a531d68..23c022a7ed9 100644 --- a/Userland/Libraries/LibChess/UCICommand.cpp +++ b/Userland/Libraries/LibChess/UCICommand.cpp @@ -98,10 +98,10 @@ SetOptionCommand SetOptionCommand::from_string(StringView command) String SetOptionCommand::to_string() const { StringBuilder builder; - builder.append("setoption name "); + builder.append("setoption name "sv); builder.append(name()); if (value().has_value()) { - builder.append(" value "); + builder.append(" value "sv); builder.append(value().value()); } builder.append('\n'); @@ -129,13 +129,13 @@ PositionCommand PositionCommand::from_string(StringView command) String PositionCommand::to_string() const { StringBuilder builder; - builder.append("position "); + builder.append("position "sv); if (fen().has_value()) { builder.append(fen().value()); } else { - builder.append("startpos "); + builder.append("startpos "sv); } - builder.append("moves"); + builder.append("moves"sv); for (auto& move : moves()) { builder.append(' '); builder.append(move.to_long_algebraic()); @@ -193,10 +193,10 @@ GoCommand GoCommand::from_string(StringView command) String GoCommand::to_string() const { StringBuilder builder; - builder.append("go"); + builder.append("go"sv); if (searchmoves.has_value()) { - builder.append(" searchmoves"); + builder.append(" searchmoves"sv); for (auto& move : searchmoves.value()) { builder.append(' '); builder.append(move.to_long_algebraic()); @@ -204,7 +204,7 @@ String GoCommand::to_string() const } if (ponder) - builder.append(" ponder"); + builder.append(" ponder"sv); if (wtime.has_value()) builder.appendff(" wtime {}", wtime.value()); if (btime.has_value()) @@ -224,7 +224,7 @@ String GoCommand::to_string() const if (movetime.has_value()) builder.appendff(" movetime {}", movetime.value()); if (infinite) - builder.append(" infinite"); + builder.append(" infinite"sv); builder.append('\n'); return builder.build(); @@ -266,11 +266,11 @@ IdCommand IdCommand::from_string(StringView command) String IdCommand::to_string() const { StringBuilder builder; - builder.append("id "); + builder.append("id "sv); if (field_type() == Type::Name) { - builder.append("name "); + builder.append("name "sv); } else { - builder.append("author "); + builder.append("author "sv); } builder.append(value()); builder.append('\n'); @@ -314,7 +314,7 @@ BestMoveCommand BestMoveCommand::from_string(StringView command) String BestMoveCommand::to_string() const { StringBuilder builder; - builder.append("bestmove "); + builder.append("bestmove "sv); builder.append(move().to_long_algebraic()); builder.append('\n'); return builder.build(); diff --git a/Userland/Libraries/LibChess/UCIEndpoint.cpp b/Userland/Libraries/LibChess/UCIEndpoint.cpp index 6c107a101cb..be23d6bc7c5 100644 --- a/Userland/Libraries/LibChess/UCIEndpoint.cpp +++ b/Userland/Libraries/LibChess/UCIEndpoint.cpp @@ -76,27 +76,27 @@ NonnullOwnPtr Endpoint::read_command() if (line == "uci") { return make(UCICommand::from_string(line)); - } else if (line.starts_with("debug")) { + } else if (line.starts_with("debug"sv)) { return make(DebugCommand::from_string(line)); - } else if (line.starts_with("isready")) { + } else if (line.starts_with("isready"sv)) { return make(IsReadyCommand::from_string(line)); - } else if (line.starts_with("setoption")) { + } else if (line.starts_with("setoption"sv)) { return make(SetOptionCommand::from_string(line)); - } else if (line.starts_with("position")) { + } else if (line.starts_with("position"sv)) { return make(PositionCommand::from_string(line)); - } else if (line.starts_with("go")) { + } else if (line.starts_with("go"sv)) { return make(GoCommand::from_string(line)); - } else if (line.starts_with("stop")) { + } else if (line.starts_with("stop"sv)) { return make(StopCommand::from_string(line)); - } else if (line.starts_with("id")) { + } else if (line.starts_with("id"sv)) { return make(IdCommand::from_string(line)); - } else if (line.starts_with("uciok")) { + } else if (line.starts_with("uciok"sv)) { return make(UCIOkCommand::from_string(line)); - } else if (line.starts_with("readyok")) { + } else if (line.starts_with("readyok"sv)) { return make(ReadyOkCommand::from_string(line)); - } else if (line.starts_with("bestmove")) { + } else if (line.starts_with("bestmove"sv)) { return make(BestMoveCommand::from_string(line)); - } else if (line.starts_with("info")) { + } else if (line.starts_with("info"sv)) { return make(InfoCommand::from_string(line)); } diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp index 7cfed25df14..c32aa6345be 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/CppComprehensionEngine.cpp @@ -740,7 +740,7 @@ Optional> CppComprehensionEng // FIXME: Don't dismiss the autocomplete when filling these suggestions. auto completion = String::formatted("{}{}{}/", prefix, include_dir, path); options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path, CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying::No); - } else if (path.ends_with(".h")) { + } else if (path.ends_with(".h"sv)) { // FIXME: Place the cursor after the trailing > or ", even if it was // already typed. auto completion = String::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix); @@ -784,7 +784,7 @@ CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(St CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(StringView qualified_name) { - auto parts = qualified_name.split_view("::"); + auto parts = qualified_name.split_view("::"sv); VERIFY(!parts.is_empty()); auto name = parts.take_last(); return SymbolName::create(name, move(parts)); diff --git a/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp index 890a0c532ec..ad0fe9809d0 100644 --- a/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp +++ b/Userland/Libraries/LibCodeComprehension/Cpp/Tests.cpp @@ -33,7 +33,7 @@ static bool s_some_test_failed = false; return; \ } while (0) -constexpr char TESTS_ROOT_DIR[] = "/home/anon/Tests/cpp-tests/comprehension"; +constexpr auto TESTS_ROOT_DIR = "/home/anon/Tests/cpp-tests/comprehension"sv; class FileDB : public CodeComprehension::FileDB { public: diff --git a/Userland/Libraries/LibCore/Account.cpp b/Userland/Libraries/LibCore/Account.cpp index 77ce8e6efd3..98cbd41bdd9 100644 --- a/Userland/Libraries/LibCore/Account.cpp +++ b/Userland/Libraries/LibCore/Account.cpp @@ -32,7 +32,7 @@ static String get_salt() fill_with_random(random_data, sizeof(random_data)); StringBuilder builder; - builder.append("$5$"); + builder.append("$5$"sv); builder.append(encode_base64(ReadonlyBytes(random_data, sizeof(random_data)))); return builder.build(); diff --git a/Userland/Libraries/LibCore/ArgsParser.cpp b/Userland/Libraries/LibCore/ArgsParser.cpp index 798a89fa2ba..570a314314d 100644 --- a/Userland/Libraries/LibCore/ArgsParser.cpp +++ b/Userland/Libraries/LibCore/ArgsParser.cpp @@ -743,7 +743,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span(); + auto address = request.get("address"sv).to_number(); for (auto& object : Object::all_objects()) { if ((FlatPtr)&object == address) { if (auto inspected_object = m_inspected_object.strong_ref()) @@ -269,10 +269,10 @@ public: } if (type == "SetProperty") { - auto address = request.get("address").to_number(); + auto address = request.get("address"sv).to_number(); for (auto& object : Object::all_objects()) { if ((FlatPtr)&object == address) { - bool success = object.set_property(request.get("name").to_string(), request.get("value")); + bool success = object.set_property(request.get("name"sv).to_string(), request.get("value"sv)); JsonObject response; response.set("type", "SetProperty"); response.set("success", success); diff --git a/Userland/Libraries/LibCore/FileWatcher.h b/Userland/Libraries/LibCore/FileWatcher.h index c8d70011dd6..b19f844fcab 100644 --- a/Userland/Libraries/LibCore/FileWatcher.h +++ b/Userland/Libraries/LibCore/FileWatcher.h @@ -87,7 +87,7 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Core::FileWatcherEvent const& value) { - return Formatter::format(builder, "FileWatcherEvent(\"{}\", {})", value.event_path, value.type); + return Formatter::format(builder, "FileWatcherEvent(\"{}\", {})"sv, value.event_path, value.type); } }; @@ -95,22 +95,22 @@ template<> struct Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Core::FileWatcherEvent::Type const& value) { - char const* type; + StringView type; switch (value) { case Core::FileWatcherEvent::Type::ChildCreated: - type = "ChildCreated"; + type = "ChildCreated"sv; break; case Core::FileWatcherEvent::Type::ChildDeleted: - type = "ChildDeleted"; + type = "ChildDeleted"sv; break; case Core::FileWatcherEvent::Type::Deleted: - type = "Deleted"; + type = "Deleted"sv; break; case Core::FileWatcherEvent::Type::ContentModified: - type = "ContentModified"; + type = "ContentModified"sv; break; case Core::FileWatcherEvent::Type::MetadataModified: - type = "MetadataModified"; + type = "MetadataModified"sv; break; default: VERIFY_NOT_REACHED(); diff --git a/Userland/Libraries/LibCore/LocalServer.cpp b/Userland/Libraries/LibCore/LocalServer.cpp index fcbd687278a..6430fd6d219 100644 --- a/Userland/Libraries/LibCore/LocalServer.cpp +++ b/Userland/Libraries/LibCore/LocalServer.cpp @@ -120,7 +120,7 @@ ErrorOr> LocalServer::accept() int accepted_fd = ::accept(m_fd, (sockaddr*)&un, &un_size); #endif if (accepted_fd < 0) { - return Error::from_syscall("accept", -errno); + return Error::from_syscall("accept"sv, -errno); } #ifdef AK_OS_MACOS diff --git a/Userland/Libraries/LibCore/MimeData.cpp b/Userland/Libraries/LibCore/MimeData.cpp index 4ee2a3d9558..23aac4c3200 100644 --- a/Userland/Libraries/LibCore/MimeData.cpp +++ b/Userland/Libraries/LibCore/MimeData.cpp @@ -53,54 +53,54 @@ void MimeData::set_text(String const& text) String guess_mime_type_based_on_filename(StringView path) { - if (path.ends_with(".pbm", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".pbm"sv, CaseSensitivity::CaseInsensitive)) return "image/x‑portable‑bitmap"; - if (path.ends_with(".pgm", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".pgm"sv, CaseSensitivity::CaseInsensitive)) return "image/x‑portable‑graymap"; - if (path.ends_with(".png", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".png"sv, CaseSensitivity::CaseInsensitive)) return "image/png"; - if (path.ends_with(".ppm", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".ppm"sv, CaseSensitivity::CaseInsensitive)) return "image/x‑portable‑pixmap"; - if (path.ends_with(".gif", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".gif"sv, CaseSensitivity::CaseInsensitive)) return "image/gif"; - if (path.ends_with(".bmp", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".bmp"sv, CaseSensitivity::CaseInsensitive)) return "image/bmp"; - if (path.ends_with(".jpg", CaseSensitivity::CaseInsensitive) || path.ends_with(".jpeg", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".jpg"sv, CaseSensitivity::CaseInsensitive) || path.ends_with(".jpeg"sv, CaseSensitivity::CaseInsensitive)) return "image/jpeg"; - if (path.ends_with(".qoi", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".qoi"sv, CaseSensitivity::CaseInsensitive)) return "image/x-qoi"; - if (path.ends_with(".svg", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".svg"sv, CaseSensitivity::CaseInsensitive)) return "image/svg+xml"; - if (path.ends_with(".md", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".md"sv, CaseSensitivity::CaseInsensitive)) return "text/markdown"; - if (path.ends_with(".html", CaseSensitivity::CaseInsensitive) || path.ends_with(".htm", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".html"sv, CaseSensitivity::CaseInsensitive) || path.ends_with(".htm"sv, CaseSensitivity::CaseInsensitive)) return "text/html"; - if (path.ends_with(".css", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".css"sv, CaseSensitivity::CaseInsensitive)) return "text/css"; - if (path.ends_with(".js", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".js"sv, CaseSensitivity::CaseInsensitive)) return "application/javascript"; - if (path.ends_with(".json", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".json"sv, CaseSensitivity::CaseInsensitive)) return "application/json"; - if (path.ends_with(".zip", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".zip"sv, CaseSensitivity::CaseInsensitive)) return "application/zip"; - if (path.ends_with(".md", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".md"sv, CaseSensitivity::CaseInsensitive)) return "text/markdown"; - if (path.ends_with("/", CaseSensitivity::CaseInsensitive)) + if (path.ends_with("/"sv, CaseSensitivity::CaseInsensitive)) return "text/html"; - if (path.ends_with(".csv", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".csv"sv, CaseSensitivity::CaseInsensitive)) return "text/csv"; - if (path.ends_with(".sheets", CaseSensitivity::CaseInsensitive)) + if (path.ends_with(".sheets"sv, CaseSensitivity::CaseInsensitive)) return "application/x-sheets+json"; // FIXME: Share this, TextEditor and HackStudio language detection somehow. auto basename = LexicalPath::basename(path); - if (path.ends_with(".cpp", CaseSensitivity::CaseInsensitive) - || path.ends_with(".c", CaseSensitivity::CaseInsensitive) - || path.ends_with(".hpp", CaseSensitivity::CaseInsensitive) - || path.ends_with(".h", CaseSensitivity::CaseInsensitive) - || path.ends_with(".gml", CaseSensitivity::CaseInsensitive) - || path.ends_with(".ini", CaseSensitivity::CaseInsensitive) - || path.ends_with(".ipc", CaseSensitivity::CaseInsensitive) - || path.ends_with(".txt", CaseSensitivity::CaseInsensitive) + if (path.ends_with(".cpp"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".c"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".hpp"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".h"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".gml"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".ini"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".ipc"sv, CaseSensitivity::CaseInsensitive) + || path.ends_with(".txt"sv, CaseSensitivity::CaseInsensitive) || basename == "CMakeLists.txt" || basename == ".history" || basename == ".shellrc") diff --git a/Userland/Libraries/LibCore/Object.h b/Userland/Libraries/LibCore/Object.h index 7e361b4fd7e..33a1fbf4433 100644 --- a/Userland/Libraries/LibCore/Object.h +++ b/Userland/Libraries/LibCore/Object.h @@ -22,18 +22,18 @@ namespace Core { -#define REGISTER_ABSTRACT_CORE_OBJECT(namespace_, class_name) \ - namespace Core { \ - namespace Registration { \ - Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return RefPtr(); }); \ - } \ +#define REGISTER_ABSTRACT_CORE_OBJECT(namespace_, class_name) \ + namespace Core { \ + namespace Registration { \ + Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name##sv, []() { return RefPtr(); }); \ + } \ } -#define REGISTER_CORE_OBJECT(namespace_, class_name) \ - namespace Core { \ - namespace Registration { \ - Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name, []() { return namespace_::class_name::construct(); }); \ - } \ +#define REGISTER_CORE_OBJECT(namespace_, class_name) \ + namespace Core { \ + namespace Registration { \ + Core::ObjectClassRegistration registration_##class_name(#namespace_ "::" #class_name##sv, []() { return namespace_::class_name::construct(); }); \ + } \ } class ObjectClassRegistration { @@ -67,7 +67,7 @@ enum class TimerShouldFireWhenNotVisible { #define C_OBJECT(klass) \ public: \ - virtual StringView class_name() const override { return #klass; } \ + virtual StringView class_name() const override { return #klass##sv; } \ template \ static NonnullRefPtr construct(Args&&... args) \ { \ @@ -81,7 +81,7 @@ public: #define C_OBJECT_ABSTRACT(klass) \ public: \ - virtual StringView class_name() const override { return #klass; } + virtual StringView class_name() const override { return #klass##sv; } class Object : public RefCounted @@ -215,7 +215,7 @@ template<> struct AK::Formatter : AK::Formatter { ErrorOr format(FormatBuilder& builder, Core::Object const& value) { - return AK::Formatter::format(builder, "{}({})", value.class_name(), &value); + return AK::Formatter::format(builder, "{}({})"sv, value.class_name(), &value); } }; @@ -306,28 +306,28 @@ T* Object::find_descendant_of_type_named(String const& name) requires IsBaseOfgetter(); \ - JsonObject rect_object; \ - rect_object.set("x", rect.x()); \ - rect_object.set("y", rect.y()); \ - rect_object.set("width", rect.width()); \ - rect_object.set("height", rect.height()); \ - return rect_object; \ - }, \ - [this](auto& value) { \ - if (!value.is_object()) \ - return false; \ - Gfx::IntRect rect; \ - rect.set_x(value.as_object().get("x").to_i32()); \ - rect.set_y(value.as_object().get("y").to_i32()); \ - rect.set_width(value.as_object().get("width").to_i32()); \ - rect.set_height(value.as_object().get("height").to_i32()); \ - setter(rect); \ - return true; \ +#define REGISTER_RECT_PROPERTY(property_name, getter, setter) \ + register_property( \ + property_name, \ + [this] { \ + auto rect = this->getter(); \ + JsonObject rect_object; \ + rect_object.set("x"sv, rect.x()); \ + rect_object.set("y"sv, rect.y()); \ + rect_object.set("width"sv, rect.width()); \ + rect_object.set("height"sv, rect.height()); \ + return rect_object; \ + }, \ + [this](auto& value) { \ + if (!value.is_object()) \ + return false; \ + Gfx::IntRect rect; \ + rect.set_x(value.as_object().get("x"sv).to_i32()); \ + rect.set_y(value.as_object().get("y"sv).to_i32()); \ + rect.set_width(value.as_object().get("width"sv).to_i32()); \ + rect.set_height(value.as_object().get("height"sv).to_i32()); \ + setter(rect); \ + return true; \ }); #define REGISTER_SIZE_PROPERTY(property_name, getter, setter) \ diff --git a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp index 9a9176d4a72..979c1bc3f9e 100644 --- a/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp +++ b/Userland/Libraries/LibCore/ProcessStatisticsReader.cpp @@ -39,56 +39,56 @@ Optional ProcessStatisticsReader::get_all(RefPtras_array(); + auto& thread_array = process_object.get_ptr("threads"sv)->as_array(); process.threads.ensure_capacity(thread_array.size()); thread_array.for_each([&](auto& value) { auto& thread_object = value.as_object(); Core::ThreadStatistics thread; - thread.tid = thread_object.get("tid").to_u32(); - thread.times_scheduled = thread_object.get("times_scheduled").to_u32(); - thread.name = thread_object.get("name").to_string(); - thread.state = thread_object.get("state").to_string(); - thread.time_user = thread_object.get("time_user").to_u64(); - thread.time_kernel = thread_object.get("time_kernel").to_u64(); - thread.cpu = thread_object.get("cpu").to_u32(); - thread.priority = thread_object.get("priority").to_u32(); - thread.syscall_count = thread_object.get("syscall_count").to_u32(); - thread.inode_faults = thread_object.get("inode_faults").to_u32(); - thread.zero_faults = thread_object.get("zero_faults").to_u32(); - thread.cow_faults = thread_object.get("cow_faults").to_u32(); - thread.unix_socket_read_bytes = thread_object.get("unix_socket_read_bytes").to_u32(); - thread.unix_socket_write_bytes = thread_object.get("unix_socket_write_bytes").to_u32(); - thread.ipv4_socket_read_bytes = thread_object.get("ipv4_socket_read_bytes").to_u32(); - thread.ipv4_socket_write_bytes = thread_object.get("ipv4_socket_write_bytes").to_u32(); - thread.file_read_bytes = thread_object.get("file_read_bytes").to_u32(); - thread.file_write_bytes = thread_object.get("file_write_bytes").to_u32(); + thread.tid = thread_object.get("tid"sv).to_u32(); + thread.times_scheduled = thread_object.get("times_scheduled"sv).to_u32(); + thread.name = thread_object.get("name"sv).to_string(); + thread.state = thread_object.get("state"sv).to_string(); + thread.time_user = thread_object.get("time_user"sv).to_u64(); + thread.time_kernel = thread_object.get("time_kernel"sv).to_u64(); + thread.cpu = thread_object.get("cpu"sv).to_u32(); + thread.priority = thread_object.get("priority"sv).to_u32(); + thread.syscall_count = thread_object.get("syscall_count"sv).to_u32(); + thread.inode_faults = thread_object.get("inode_faults"sv).to_u32(); + thread.zero_faults = thread_object.get("zero_faults"sv).to_u32(); + thread.cow_faults = thread_object.get("cow_faults"sv).to_u32(); + thread.unix_socket_read_bytes = thread_object.get("unix_socket_read_bytes"sv).to_u32(); + thread.unix_socket_write_bytes = thread_object.get("unix_socket_write_bytes"sv).to_u32(); + thread.ipv4_socket_read_bytes = thread_object.get("ipv4_socket_read_bytes"sv).to_u32(); + thread.ipv4_socket_write_bytes = thread_object.get("ipv4_socket_write_bytes"sv).to_u32(); + thread.file_read_bytes = thread_object.get("file_read_bytes"sv).to_u32(); + thread.file_write_bytes = thread_object.get("file_write_bytes"sv).to_u32(); process.threads.append(move(thread)); }); @@ -97,8 +97,8 @@ Optional ProcessStatisticsReader::get_all(RefPtr Socket::resolve_host(String const& host, SocketType type) int rc = getaddrinfo(host.characters(), nullptr, &hints, &results); if (rc != 0) { if (rc == EAI_SYSTEM) { - return Error::from_syscall("getaddrinfo", -errno); + return Error::from_syscall("getaddrinfo"sv, -errno); } auto const* error_string = gai_strerror(rc); @@ -423,7 +423,7 @@ ErrorOr PosixSocketHelper::can_read_without_blocking(int timeout) const } while (rc < 0 && errno == EINTR); if (rc < 0) { - return Error::from_syscall("poll", -errno); + return Error::from_syscall("poll"sv, -errno); } return (the_fd.revents & POLLIN) > 0; diff --git a/Userland/Libraries/LibCore/System.cpp b/Userland/Libraries/LibCore/System.cpp index e5183206144..a3b1972bdf8 100644 --- a/Userland/Libraries/LibCore/System.cpp +++ b/Userland/Libraries/LibCore/System.cpp @@ -44,7 +44,7 @@ static int memfd_create(char const* name, unsigned int flags) #define HANDLE_SYSCALL_RETURN_VALUE(syscall_name, rc, success_value) \ if ((rc) < 0) { \ - return Error::from_syscall(syscall_name, rc); \ + return Error::from_syscall(syscall_name##sv, rc); \ } \ return success_value; @@ -75,7 +75,7 @@ ErrorOr pledge(StringView promises, StringView execpromises) { execpromises.characters_without_null_termination(), execpromises.length() }, }; int rc = syscall(SC_pledge, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("pledge"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("pledge", rc, {}); } ErrorOr unveil(StringView path, StringView permissions) @@ -85,7 +85,7 @@ ErrorOr unveil(StringView path, StringView permissions) { permissions.characters_without_null_termination(), permissions.length() }, }; int rc = syscall(SC_unveil, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("unveil"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("unveil", rc, {}); } ErrorOr sendfd(int sockfd, int fd) @@ -342,7 +342,7 @@ ErrorOr openat(int fd, StringView path, int options, mode_t mode) #ifdef __serenity__ Syscall::SC_open_params params { fd, { path.characters_without_null_termination(), path.length() }, options, mode }; int rc = syscall(SC_open, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("open"sv, rc, rc); + HANDLE_SYSCALL_RETURN_VALUE("open", rc, rc); #else // NOTE: We have to ensure that the path is null-terminated. String path_string = path; @@ -376,7 +376,7 @@ ErrorOr stat(StringView path) #ifdef __serenity__ Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, AT_FDCWD, true }; int rc = syscall(SC_stat, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("stat"sv, rc, st); + HANDLE_SYSCALL_RETURN_VALUE("stat", rc, st); #else String path_string = path; if (::stat(path_string.characters(), &st) < 0) @@ -394,7 +394,7 @@ ErrorOr lstat(StringView path) #ifdef __serenity__ Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, AT_FDCWD, false }; int rc = syscall(SC_stat, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("lstat"sv, rc, st); + HANDLE_SYSCALL_RETURN_VALUE("lstat", rc, st); #else String path_string = path; if (::stat(path_string.characters(), &st) < 0) @@ -532,7 +532,7 @@ ErrorOr chmod(StringView pathname, mode_t mode) true }; int rc = syscall(SC_chmod, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("chmod"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("chmod", rc, {}); #else String path = pathname; if (::chmod(path.characters(), mode) < 0) @@ -563,7 +563,7 @@ ErrorOr lchown(StringView pathname, uid_t uid, gid_t gid) #ifdef __serenity__ Syscall::SC_chown_params params = { { pathname.characters_without_null_termination(), pathname.length() }, uid, gid, AT_FDCWD, false }; int rc = syscall(SC_chown, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("chown"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {}); #else String path = pathname; if (::chown(path.characters(), uid, gid) < 0) @@ -580,7 +580,7 @@ ErrorOr chown(StringView pathname, uid_t uid, gid_t gid) #ifdef __serenity__ Syscall::SC_chown_params params = { { pathname.characters_without_null_termination(), pathname.length() }, uid, gid, AT_FDCWD, true }; int rc = syscall(SC_chown, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("chown"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {}); #else String path = pathname; if (::lchown(path.characters(), uid, gid) < 0) @@ -653,7 +653,7 @@ ErrorOr clock_settime(clockid_t clock_id, struct timespec* ts) { #ifdef __serenity__ int rc = syscall(SC_clock_settime, clock_id, ts); - HANDLE_SYSCALL_RETURN_VALUE("clocksettime"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("clocksettime", rc, {}); #else if (::clock_settime(clock_id, ts) < 0) return Error::from_syscall("clocksettime"sv, -errno); @@ -683,7 +683,7 @@ ErrorOr lseek(int fd, off_t offset, int whence) { off_t rc = ::lseek(fd, offset, whence); if (rc < 0) - return Error::from_syscall("lseek", -errno); + return Error::from_syscall("lseek"sv, -errno); return rc; } @@ -693,7 +693,7 @@ ErrorOr endgrent() swap(old_errno, errno); ::endgrent(); if (errno != 0) - return Error::from_syscall("endgrent", -errno); + return Error::from_syscall("endgrent"sv, -errno); errno = old_errno; return {}; } @@ -777,7 +777,7 @@ ErrorOr symlink(StringView target, StringView link_path) .linkpath = { link_path.characters_without_null_termination(), link_path.length() }, }; int rc = syscall(SC_symlink, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("symlink"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("symlink", rc, {}); #else String target_string = target; String link_path_string = link_path; @@ -793,7 +793,7 @@ ErrorOr mkdir(StringView path, mode_t mode) return Error::from_errno(EFAULT); #ifdef __serenity__ int rc = syscall(SC_mkdir, path.characters_without_null_termination(), path.length(), mode); - HANDLE_SYSCALL_RETURN_VALUE("mkdir"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("mkdir", rc, {}); #else String path_string = path; if (::mkdir(path_string.characters(), mode) < 0) @@ -808,7 +808,7 @@ ErrorOr chdir(StringView path) return Error::from_errno(EFAULT); #ifdef __serenity__ int rc = syscall(SC_chdir, path.characters_without_null_termination(), path.length()); - HANDLE_SYSCALL_RETURN_VALUE("chdir"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("chdir", rc, {}); #else String path_string = path; if (::chdir(path_string.characters()) < 0) @@ -823,7 +823,7 @@ ErrorOr rmdir(StringView path) return Error::from_errno(EFAULT); #ifdef __serenity__ int rc = syscall(SC_rmdir, path.characters_without_null_termination(), path.length()); - HANDLE_SYSCALL_RETURN_VALUE("rmdir"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("rmdir", rc, {}); #else String path_string = path; if (::rmdir(path_string.characters()) < 0) @@ -859,7 +859,7 @@ ErrorOr rename(StringView old_path, StringView new_path) .new_path = { new_path.characters_without_null_termination(), new_path.length() }, }; int rc = syscall(SC_rename, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("rename"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("rename", rc, {}); #else String old_path_string = old_path; String new_path_string = new_path; @@ -876,7 +876,7 @@ ErrorOr unlink(StringView path) #ifdef __serenity__ int rc = syscall(SC_unlink, AT_FDCWD, path.characters_without_null_termination(), path.length(), 0); - HANDLE_SYSCALL_RETURN_VALUE("unlink"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("unlink", rc, {}); #else String path_string = path; if (::unlink(path_string.characters()) < 0) @@ -895,7 +895,7 @@ ErrorOr utime(StringView path, Optional maybe_buf) buf = &maybe_buf.value(); #ifdef __serenity__ int rc = syscall(SC_utime, path.characters_without_null_termination(), path.length(), buf); - HANDLE_SYSCALL_RETURN_VALUE("utime"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("utime", rc, {}); #else String path_string = path; if (::utime(path_string.characters(), buf) < 0) @@ -909,7 +909,7 @@ ErrorOr uname() utsname uts; #ifdef __serenity__ int rc = syscall(SC_uname, &uts); - HANDLE_SYSCALL_RETURN_VALUE("uname"sv, rc, uts); + HANDLE_SYSCALL_RETURN_VALUE("uname", rc, uts); #else if (::uname(&uts) < 0) return Error::from_syscall("uname"sv, -errno); @@ -921,7 +921,7 @@ ErrorOr adjtime(const struct timeval* delta, struct timeval* old_delta) { #ifdef __serenity__ int rc = syscall(SC_adjtime, delta, old_delta); - HANDLE_SYSCALL_RETURN_VALUE("adjtime"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("adjtime", rc, {}); #else if (::adjtime(delta, old_delta) < 0) return Error::from_syscall("adjtime"sv, -errno); @@ -973,7 +973,7 @@ ErrorOr exec(StringView filename, Span arguments, SearchInPath auto const* path_ptr = getenv("PATH"); StringView path { path_ptr, strlen(path_ptr) }; if (path.is_empty()) - path = "/bin:/usr/bin"; + path = "/bin:/usr/bin"sv; auto parts = path.split_view(':'); for (auto& part : parts) { auto candidate = String::formatted("{}/{}", part, filename); @@ -1214,7 +1214,7 @@ ErrorOr mknod(StringView pathname, mode_t mode, dev_t dev) #ifdef __serenity__ Syscall::SC_mknod_params params { { pathname.characters_without_null_termination(), pathname.length() }, mode, dev }; int rc = syscall(SC_mknod, ¶ms); - HANDLE_SYSCALL_RETURN_VALUE("mknod"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("mknod", rc, {}); #else String path_string = pathname; if (::mknod(path_string.characters(), mode, dev) < 0) @@ -1238,7 +1238,7 @@ ErrorOr setenv(StringView name, StringView value, bool overwrite) auto const rc = ::setenv(name_string.characters(), value_string.characters(), overwrite); #endif if (rc < 0) - return Error::from_syscall("setenv", -errno); + return Error::from_syscall("setenv"sv, -errno); return {}; } @@ -1246,7 +1246,7 @@ ErrorOr posix_openpt(int flags) { int const rc = ::posix_openpt(flags); if (rc < 0) - return Error::from_syscall("posix_openpt", -errno); + return Error::from_syscall("posix_openpt"sv, -errno); return rc; } @@ -1254,7 +1254,7 @@ ErrorOr grantpt(int fildes) { auto const rc = ::grantpt(fildes); if (rc < 0) - return Error::from_syscall("grantpt", -errno); + return Error::from_syscall("grantpt"sv, -errno); return {}; } @@ -1262,7 +1262,7 @@ ErrorOr unlockpt(int fildes) { auto const rc = ::unlockpt(fildes); if (rc < 0) - return Error::from_syscall("unlockpt", -errno); + return Error::from_syscall("unlockpt"sv, -errno); return {}; } @@ -1273,7 +1273,7 @@ ErrorOr access(StringView pathname, int mode) #ifdef __serenity__ int rc = ::syscall(Syscall::SC_access, pathname.characters_without_null_termination(), pathname.length(), mode); - HANDLE_SYSCALL_RETURN_VALUE("access"sv, rc, {}); + HANDLE_SYSCALL_RETURN_VALUE("access", rc, {}); #else String path_string = pathname; if (::access(path_string.characters(), mode) < 0) diff --git a/Userland/Libraries/LibCoredump/Backtrace.cpp b/Userland/Libraries/LibCoredump/Backtrace.cpp index f063e30c80b..5dae26eef69 100644 --- a/Userland/Libraries/LibCoredump/Backtrace.cpp +++ b/Userland/Libraries/LibCoredump/Backtrace.cpp @@ -127,11 +127,11 @@ String Backtrace::Entry::to_string(bool color) const StringBuilder builder; builder.appendff("{:p}: ", eip); if (object_name.is_empty()) { - builder.append("???"); + builder.append("???"sv); return builder.build(); } builder.appendff("[{}] {}", object_name, function_name.is_empty() ? "???" : function_name); - builder.append(" ("); + builder.append(" ("sv); Vector source_positions; @@ -146,10 +146,10 @@ String Backtrace::Entry::to_string(bool color) const for (size_t i = 0; i < source_positions.size(); ++i) { auto& position = source_positions[i]; - auto fmt = color ? "\033[34;1m{}\033[0m:{}" : "{}:{}"; + auto fmt = color ? "\033[34;1m{}\033[0m:{}"sv : "{}:{}"sv; builder.appendff(fmt, LexicalPath::basename(position.file_path), position.line_number); if (i != source_positions.size() - 1) { - builder.append(" => "); + builder.append(" => "sv); } } diff --git a/Userland/Libraries/LibCoredump/Reader.cpp b/Userland/Libraries/LibCoredump/Reader.cpp index 05c77f8584d..ed38e8b41f5 100644 --- a/Userland/Libraries/LibCoredump/Reader.cpp +++ b/Userland/Libraries/LibCoredump/Reader.cpp @@ -196,14 +196,14 @@ Optional Reader::region_containing(FlatPtr address) const int Reader::process_pid() const { auto process_info = this->process_info(); - auto pid = process_info.get("pid"); + auto pid = process_info.get("pid"sv); return pid.to_number(); } u8 Reader::process_termination_signal() const { auto process_info = this->process_info(); - auto termination_signal = process_info.get("termination_signal"); + auto termination_signal = process_info.get("termination_signal"sv); auto signal_number = termination_signal.to_number(); if (signal_number <= SIGINVAL || signal_number >= NSIG) return SIGINVAL; @@ -213,14 +213,14 @@ u8 Reader::process_termination_signal() const String Reader::process_executable_path() const { auto process_info = this->process_info(); - auto executable_path = process_info.get("executable_path"); + auto executable_path = process_info.get("executable_path"sv); return executable_path.as_string_or({}); } Vector Reader::process_arguments() const { auto process_info = this->process_info(); - auto arguments = process_info.get("arguments"); + auto arguments = process_info.get("arguments"sv); if (!arguments.is_array()) return {}; Vector vector; @@ -234,7 +234,7 @@ Vector Reader::process_arguments() const Vector Reader::process_environment() const { auto process_info = this->process_info(); - auto environment = process_info.get("environment"); + auto environment = process_info.get("environment"sv); if (!environment.is_array()) return {}; Vector vector; diff --git a/Userland/Libraries/LibCoredump/Reader.h b/Userland/Libraries/LibCoredump/Reader.h index 48a5fca3558..3e99ec88fa4 100644 --- a/Userland/Libraries/LibCoredump/Reader.h +++ b/Userland/Libraries/LibCoredump/Reader.h @@ -26,7 +26,7 @@ struct MemoryRegionInfo { StringView object_name() const { - if (region_name.contains("Loader.so")) + if (region_name.contains("Loader.so"sv)) return "Loader.so"sv; auto maybe_colon_index = region_name.find(':'); if (!maybe_colon_index.has_value()) diff --git a/Userland/Libraries/LibCpp/AST.cpp b/Userland/Libraries/LibCpp/AST.cpp index 65483a54269..19f2b60ccad 100644 --- a/Userland/Libraries/LibCpp/AST.cpp +++ b/Userland/Libraries/LibCpp/AST.cpp @@ -85,7 +85,7 @@ String NamedType::to_string() const if (is_auto()) name = "auto"; else - name = m_name.is_null() ? "" : m_name->full_name(); + name = m_name.is_null() ? ""sv : m_name->full_name(); return String::formatted("{}{}", qualifiers_string, name); } @@ -109,7 +109,7 @@ String Reference::to_string() const if (m_kind == Kind::Lvalue) builder.append("&"); else - builder.append("&&"); + builder.append("&&"sv); return builder.to_string(); } @@ -123,7 +123,7 @@ String FunctionType::to_string() const if (first) first = false; else - builder.append(", "); + builder.append(", "sv); if (parameter.type()) builder.append(parameter.type()->to_string()); if (parameter.name() && !parameter.full_name().is_empty()) { @@ -552,7 +552,7 @@ StringView Name::full_name() const builder.appendff("{}::", scope.name()); } } - m_full_name = String::formatted("{}{}", builder.to_string(), m_name.is_null() ? "" : m_name->name()); + m_full_name = String::formatted("{}{}", builder.to_string(), m_name.is_null() ? ""sv : m_name->name()); return *m_full_name; } diff --git a/Userland/Libraries/LibCpp/Lexer.cpp b/Userland/Libraries/LibCpp/Lexer.cpp index 5696fcad1c6..db5fc33cfa6 100644 --- a/Userland/Libraries/LibCpp/Lexer.cpp +++ b/Userland/Libraries/LibCpp/Lexer.cpp @@ -52,155 +52,155 @@ constexpr bool is_valid_nonfirst_character_of_identifier(char ch) } constexpr StringView s_known_keywords[] = { - "alignas", - "alignof", - "and", - "and_eq", - "asm", - "bitand", - "bitor", - "break", - "case", - "catch", - "class", - "compl", - "const", - "const_cast", - "constexpr", - "continue", - "decltype", - "default", - "delete", - "do", - "dynamic_cast", - "else", - "enum", - "explicit", - "export", - "extern", - "false", - "final", - "for", - "friend", - "goto", - "if", - "inline", - "mutable", - "namespace", - "new", - "noexcept", - "not", - "not_eq", - "nullptr", - "operator", - "or", - "or_eq", - "override", - "private", - "protected", - "public", - "register", - "reinterpret_cast", - "return", - "signed", - "sizeof", - "static", - "static_assert", - "static_cast", - "struct", - "switch", - "template", - "this", - "thread_local", - "throw", - "true", - "try", - "typedef", - "typeid", - "typename", - "union", - "using", - "virtual", - "volatile", - "while", - "xor", - "xor_eq" + "alignas"sv, + "alignof"sv, + "and"sv, + "and_eq"sv, + "asm"sv, + "bitand"sv, + "bitor"sv, + "break"sv, + "case"sv, + "catch"sv, + "class"sv, + "compl"sv, + "const"sv, + "const_cast"sv, + "constexpr"sv, + "continue"sv, + "decltype"sv, + "default"sv, + "delete"sv, + "do"sv, + "dynamic_cast"sv, + "else"sv, + "enum"sv, + "explicit"sv, + "export"sv, + "extern"sv, + "false"sv, + "final"sv, + "for"sv, + "friend"sv, + "goto"sv, + "if"sv, + "inline"sv, + "mutable"sv, + "namespace"sv, + "new"sv, + "noexcept"sv, + "not"sv, + "not_eq"sv, + "nullptr"sv, + "operator"sv, + "or"sv, + "or_eq"sv, + "override"sv, + "private"sv, + "protected"sv, + "public"sv, + "register"sv, + "reinterpret_cast"sv, + "return"sv, + "signed"sv, + "sizeof"sv, + "static"sv, + "static_assert"sv, + "static_cast"sv, + "struct"sv, + "switch"sv, + "template"sv, + "this"sv, + "thread_local"sv, + "throw"sv, + "true"sv, + "try"sv, + "typedef"sv, + "typeid"sv, + "typename"sv, + "union"sv, + "using"sv, + "virtual"sv, + "volatile"sv, + "while"sv, + "xor"sv, + "xor_eq"sv }; constexpr StringView s_known_types[] = { - "Array", - "Array", - "Badge", - "Bitmap", - "ByteBuffer", - "Bytes", - "Checked", - "CircularDeque", - "CircularQueue", - "Deque", - "DoublyLinkedList", - "Error", - "ErrorOr", - "FlyString", - "Function", - "HashMap", - "HashTable", - "IPv4Address", - "IntrusiveList", - "IntrusiveList", - "JsonArray", - "JsonObject", - "JsonValue", - "LexicalPath", - "MappedFile", - "NetworkOrdered", - "NeverDestroyed", - "NonnullOwnPtr", - "NonnullOwnPtrVector", - "NonnullRefPtr", - "NonnullRefPtrVector", - "Optional", - "OwnPtr", - "ReadonlyBytes", - "RedBlackTree", - "RefPtr", - "Result", - "ScopeGuard", - "Singleton", - "SinglyLinkedList", - "Span", - "String", - "StringBuilder", - "StringImpl", - "StringView", - "Utf8View", - "Variant", - "Vector", - "WeakPtr", - "auto", - "bool", - "char", - "char16_t", - "char32_t", - "char8_t", - "double", - "float", - "i16", - "i32", - "i64", - "i8", - "int", - "int", - "long", - "short", - "signed", - "u16", - "u32", - "u64", - "u8", - "unsigned", - "void", - "wchar_t", + "Array"sv, + "Array"sv, + "Badge"sv, + "Bitmap"sv, + "ByteBuffer"sv, + "Bytes"sv, + "Checked"sv, + "CircularDeque"sv, + "CircularQueue"sv, + "Deque"sv, + "DoublyLinkedList"sv, + "Error"sv, + "ErrorOr"sv, + "FlyString"sv, + "Function"sv, + "HashMap"sv, + "HashTable"sv, + "IPv4Address"sv, + "IntrusiveList"sv, + "IntrusiveList"sv, + "JsonArray"sv, + "JsonObject"sv, + "JsonValue"sv, + "LexicalPath"sv, + "MappedFile"sv, + "NetworkOrdered"sv, + "NeverDestroyed"sv, + "NonnullOwnPtr"sv, + "NonnullOwnPtrVector"sv, + "NonnullRefPtr"sv, + "NonnullRefPtrVector"sv, + "Optional"sv, + "OwnPtr"sv, + "ReadonlyBytes"sv, + "RedBlackTree"sv, + "RefPtr"sv, + "Result"sv, + "ScopeGuard"sv, + "Singleton"sv, + "SinglyLinkedList"sv, + "Span"sv, + "String"sv, + "StringBuilder"sv, + "StringImpl"sv, + "StringView"sv, + "Utf8View"sv, + "Variant"sv, + "Vector"sv, + "WeakPtr"sv, + "auto"sv, + "bool"sv, + "char"sv, + "char16_t"sv, + "char32_t"sv, + "char8_t"sv, + "double"sv, + "float"sv, + "i16"sv, + "i32"sv, + "i64"sv, + "i8"sv, + "int"sv, + "int"sv, + "long"sv, + "short"sv, + "signed"sv, + "u16"sv, + "u32"sv, + "u64"sv, + "u8"sv, + "unsigned"sv, + "void"sv, + "wchar_t"sv, }; static bool is_keyword(StringView string) diff --git a/Userland/Libraries/LibCpp/Parser.cpp b/Userland/Libraries/LibCpp/Parser.cpp index d44a91ce12c..0ccb9afb4bd 100644 --- a/Userland/Libraries/LibCpp/Parser.cpp +++ b/Userland/Libraries/LibCpp/Parser.cpp @@ -45,7 +45,7 @@ NonnullRefPtrVector Parser::parse_declarations_in_translation_unit( if (declaration) { declarations.append(declaration.release_nonnull()); } else { - error("unexpected token"); + error("unexpected token"sv); consume(); } } @@ -92,7 +92,7 @@ NonnullRefPtr Parser::parse_declaration(ASTNode& parent, Declaratio case DeclarationType::Destructor: return parse_destructor(parent); default: - error("unexpected declaration type"); + error("unexpected declaration type"sv); return create_ast_node(parent, position(), position()); } } @@ -181,7 +181,7 @@ NonnullRefPtr Parser::parse_statement(ASTNode& parent) consume_semicolon.disarm(); return parse_if_statement(parent); } else { - error("unexpected statement type"); + error("unexpected statement type"sv); consume_semicolon.disarm(); consume(); return create_ast_node(parent, position(), position()); @@ -295,7 +295,7 @@ bool Parser::match_variable_declaration() if (match(Token::Type::Equals)) { consume(Token::Type::Equals); if (!match_expression()) { - error("initial value of variable is not an expression"); + error("initial value of variable is not an expression"sv); return false; } return true; @@ -312,7 +312,7 @@ NonnullRefPtr Parser::parse_variable_declaration(ASTNode& p LOG_SCOPE(); auto var = create_ast_node(parent, position(), {}); if (!match_variable_declaration()) { - error("unexpected token for variable type"); + error("unexpected token for variable type"sv); var->set_end(position()); return var; } @@ -432,7 +432,7 @@ NonnullRefPtr Parser::parse_primary_expression(ASTNode& parent) return parse_name(parent); } - error("could not parse primary expression"); + error("could not parse primary expression"sv); auto token = consume(); return create_ast_node(parent, token.start(), token.end()); } @@ -523,7 +523,7 @@ NonnullRefPtr Parser::parse_literal(ASTNode& parent) [[fallthrough]]; } default: { - error("could not parse literal"); + error("could not parse literal"sv); auto token = consume(); return create_ast_node(parent, token.start(), token.end()); } @@ -805,7 +805,7 @@ void Parser::consume_preprocessor() consume(Token::Type::IncludePath); break; default: - error("unexpected token while parsing preprocessor statement"); + error("unexpected token while parsing preprocessor statement"sv); consume(); } } @@ -832,7 +832,7 @@ bool Parser::match(Token::Type type) Token Parser::consume() { if (eof()) { - error("C++ Parser: out of tokens"); + error("C++ Parser: out of tokens"sv); return { Token::Type::EOF_TOKEN, position(), position(), {} }; } return m_tokens[m_state.token_index++]; @@ -905,14 +905,14 @@ void Parser::error(StringView message) return; if (message.is_null() || message.is_empty()) - message = ""; + message = ""sv; String formatted_message; if (m_state.token_index >= m_tokens.size()) { formatted_message = String::formatted("C++ Parsed error on EOF.{}", message); } else { formatted_message = String::formatted("C++ Parser error: {}. token: {} ({}:{})", message, - m_state.token_index < m_tokens.size() ? text_of_token(m_tokens[m_state.token_index]) : "EOF", + m_state.token_index < m_tokens.size() ? text_of_token(m_tokens[m_state.token_index]) : "EOF"sv, m_tokens[m_state.token_index].start().line, m_tokens[m_state.token_index].start().column); } @@ -1017,7 +1017,7 @@ Vector Parser::get_todo_entries() const Vector ret; for (auto& token : m_tokens) { if (token.type() == Token::Type::Comment) { - if (token.text().contains("TODO") || token.text().contains("FIXME")) { + if (token.text().contains("TODO"sv) || token.text().contains("FIXME"sv)) { ret.append({ token.text(), m_filename, token.start().line, token.start().column }); } } @@ -1206,7 +1206,7 @@ NonnullRefPtr Parser::parse_type(ASTNode& parent) LOG_SCOPE(); if (!match_named_type()) { - error("expected named named_type"); + error("expected named named_type"sv); auto token = consume(); return create_ast_node(parent, token.start(), token.end()); } @@ -1412,7 +1412,7 @@ NonnullRefPtr Parser::parse_namespace_declaration(ASTNode& if (declaration) { namespace_decl->add_declaration(declaration.release_nonnull()); } else { - error("unexpected token"); + error("unexpected token"sv); consume(); } } @@ -1577,7 +1577,7 @@ NonnullRefPtrVector Parser::parse_class_members(StructOrClassDeclar if (member_type.has_value()) { members.append(parse_declaration(parent, member_type.value())); } else { - error("Expected class member"); + error("Expected class member"sv); consume(); } } @@ -1661,7 +1661,7 @@ void Parser::parse_constructor_or_destructor_impl(FunctionDeclaration& func, Cto auto parameters = parse_parameter_list(func); if (parameters.has_value()) { if (type == CtorOrDtor::Dtor && !parameters->is_empty()) - error("Destructor declaration that takes parameters"); + error("Destructor declaration that takes parameters"sv); else func.set_parameters(parameters.value()); } diff --git a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp index a87e5b4f544..bdc23e33c59 100644 --- a/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/ASN1.cpp @@ -85,14 +85,14 @@ Optional parse_utc_time(StringView time) Optional seconds, offset_hours, offset_minutes; [[maybe_unused]] bool negative_offset = false; if (!lexer.next_is('Z')) { - if (!lexer.next_is(is_any_of("+-"))) { + if (!lexer.next_is(is_any_of("+-"sv))) { seconds = lexer.consume(2).to_uint(); if (!seconds.has_value()) { return {}; } } - if (lexer.next_is(is_any_of("+-"))) { + if (lexer.next_is(is_any_of("+-"sv))) { negative_offset = lexer.consume() == '-'; offset_hours = lexer.consume(2).to_uint(); offset_minutes = lexer.consume(2).to_uint(); @@ -136,7 +136,7 @@ Optional parse_generalized_time(StringView time) if (lexer.consume_specific('Z')) goto done_parsing; - if (!lexer.next_is(is_any_of("+-"))) { + if (!lexer.next_is(is_any_of("+-"sv))) { minute = lexer.consume(2).to_uint(); if (!minute.has_value()) { return {}; @@ -145,7 +145,7 @@ Optional parse_generalized_time(StringView time) goto done_parsing; } - if (!lexer.next_is(is_any_of("+-"))) { + if (!lexer.next_is(is_any_of("+-"sv))) { seconds = lexer.consume(2).to_uint(); if (!seconds.has_value()) { return {}; @@ -163,7 +163,7 @@ Optional parse_generalized_time(StringView time) goto done_parsing; } - if (lexer.next_is(is_any_of("+-"))) { + if (lexer.next_is(is_any_of("+-"sv))) { negative_offset = lexer.consume() == '-'; offset_hours = lexer.consume(2).to_uint(); offset_minutes = lexer.consume(2).to_uint(); diff --git a/Userland/Libraries/LibCrypto/ASN1/DER.cpp b/Userland/Libraries/LibCrypto/ASN1/DER.cpp index 49e0b90ba8e..f86ab6b2c8a 100644 --- a/Userland/Libraries/LibCrypto/ASN1/DER.cpp +++ b/Userland/Libraries/LibCrypto/ASN1/DER.cpp @@ -312,7 +312,7 @@ void pretty_print(Decoder& decoder, OutputStream& stream, int indent) dbgln("Integer PrettyPrint error: {}", value.error()); return; } - builder.append(" 0x"); + builder.append(" 0x"sv); for (auto ch : value.value()) builder.appendff("{:0>2x}", ch); break; @@ -323,7 +323,7 @@ void pretty_print(Decoder& decoder, OutputStream& stream, int indent) dbgln("BitString PrettyPrint error: {}", value.error()); return; } - builder.append(" 0b"); + builder.append(" 0b"sv); for (size_t i = 0; i < value.value().size(); ++i) builder.append(value.value().get(i) ? '1' : '0'); break; @@ -334,7 +334,7 @@ void pretty_print(Decoder& decoder, OutputStream& stream, int indent) dbgln("OctetString PrettyPrint error: {}", value.error()); return; } - builder.append(" 0x"); + builder.append(" 0x"sv); for (auto ch : value.value()) builder.appendff("{:0>2x}", ch); break; diff --git a/Userland/Libraries/LibCrypto/Authentication/HMAC.h b/Userland/Libraries/LibCrypto/Authentication/HMAC.h index 29c9ce13001..cb601c06225 100644 --- a/Userland/Libraries/LibCrypto/Authentication/HMAC.h +++ b/Userland/Libraries/LibCrypto/Authentication/HMAC.h @@ -77,7 +77,7 @@ public: String class_name() const { StringBuilder builder; - builder.append("HMAC-"); + builder.append("HMAC-"sv); builder.append(m_inner_hasher.class_name()); return builder.build(); } diff --git a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp index da24f95b31b..382939947a4 100644 --- a/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp +++ b/Userland/Libraries/LibCrypto/BigInt/SignedBigInteger.cpp @@ -339,6 +339,6 @@ bool SignedBigInteger::operator>=(SignedBigInteger const& other) const ErrorOr AK::Formatter::format(FormatBuilder& fmtbuilder, Crypto::SignedBigInteger const& value) { if (value.is_negative()) - TRY(fmtbuilder.put_string("-")); + TRY(fmtbuilder.put_string("-"sv)); return Formatter::format(fmtbuilder, value.unsigned_value()); } diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h index 9cc3210a7e8..04e7bf30ae8 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CBC.h @@ -34,7 +34,7 @@ public: { StringBuilder builder; builder.append(this->cipher().class_name()); - builder.append("_CBC"); + builder.append("_CBC"sv); return builder.build(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h index 3639282bf8b..009fd3b07ef 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/CTR.h @@ -109,7 +109,7 @@ public: { StringBuilder builder; builder.append(this->cipher().class_name()); - builder.append("_CTR"); + builder.append("_CTR"sv); return builder.build(); } #endif diff --git a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h index 77478ba4c9f..ade13a1ce3d 100644 --- a/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h +++ b/Userland/Libraries/LibCrypto/Cipher/Mode/GCM.h @@ -49,7 +49,7 @@ public: { StringBuilder builder; builder.append(this->cipher().class_name()); - builder.append("_GCM"); + builder.append("_GCM"sv); return builder.build(); } #endif diff --git a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp index b44e6cac0c8..08051303987 100644 --- a/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp +++ b/Userland/Libraries/LibCrypto/NumberTheory/ModularFunctions.cpp @@ -218,7 +218,7 @@ bool is_probably_prime(UnsignedBigInteger const& p) UnsignedBigInteger random_big_prime(size_t bits) { VERIFY(bits >= 33); - UnsignedBigInteger min = UnsignedBigInteger::from_base(10, "6074001000").shift_left(bits - 33); + UnsignedBigInteger min = UnsignedBigInteger::from_base(10, "6074001000"sv).shift_left(bits - 33); UnsignedBigInteger max = UnsignedBigInteger { 1 }.shift_left(bits).minus(1); for (;;) { auto p = random_number(min, max); diff --git a/Userland/Libraries/LibDNS/Answer.cpp b/Userland/Libraries/LibDNS/Answer.cpp index 4927eb7fa7c..e494d3bd8cf 100644 --- a/Userland/Libraries/LibDNS/Answer.cpp +++ b/Userland/Libraries/LibDNS/Answer.cpp @@ -62,26 +62,26 @@ ErrorOr AK::Formatter::format(AK::FormatBuilder& builder, { switch (value) { case DNS::RecordType::A: - return builder.put_string("A"); + return builder.put_string("A"sv); case DNS::RecordType::NS: - return builder.put_string("NS"); + return builder.put_string("NS"sv); case DNS::RecordType::CNAME: - return builder.put_string("CNAME"); + return builder.put_string("CNAME"sv); case DNS::RecordType::SOA: - return builder.put_string("SOA"); + return builder.put_string("SOA"sv); case DNS::RecordType::PTR: - return builder.put_string("PTR"); + return builder.put_string("PTR"sv); case DNS::RecordType::MX: - return builder.put_string("MX"); + return builder.put_string("MX"sv); case DNS::RecordType::TXT: - return builder.put_string("TXT"); + return builder.put_string("TXT"sv); case DNS::RecordType::AAAA: - return builder.put_string("AAAA"); + return builder.put_string("AAAA"sv); case DNS::RecordType::SRV: - return builder.put_string("SRV"); + return builder.put_string("SRV"sv); } - TRY(builder.put_string("DNS record type ")); + TRY(builder.put_string("DNS record type "sv)); TRY(builder.put_u64((u16)value)); return {}; } @@ -90,10 +90,10 @@ ErrorOr AK::Formatter::format(AK::FormatBuilder& builder { switch (value) { case DNS::RecordClass::IN: - return builder.put_string("IN"); + return builder.put_string("IN"sv); } - TRY(builder.put_string("DNS record class ")); + TRY(builder.put_string("DNS record class "sv)); TRY(builder.put_u64((u16)value)); return {}; } diff --git a/Userland/Libraries/LibDebug/DebugInfo.cpp b/Userland/Libraries/LibDebug/DebugInfo.cpp index 6cf6a90cf18..b4c73751ac6 100644 --- a/Userland/Libraries/LibDebug/DebugInfo.cpp +++ b/Userland/Libraries/LibDebug/DebugInfo.cpp @@ -135,9 +135,10 @@ Optional DebugInfo::get_address_from_source if (!file_path.starts_with("/")) file_path = String::formatted("/{}", file_path); - constexpr char SERENITY_LIBS_PREFIX[] = "/usr/src/serenity"; + constexpr auto SERENITY_LIBS_PREFIX = "/usr/src/serenity"sv; if (file.starts_with(SERENITY_LIBS_PREFIX)) { - file_path = file.substring(sizeof(SERENITY_LIBS_PREFIX), file.length() - sizeof(SERENITY_LIBS_PREFIX)); + size_t file_prefix_offset = SERENITY_LIBS_PREFIX.length() + 1; + file_path = file.substring(file_prefix_offset, file.length() - file_prefix_offset); file_path = String::formatted("../{}", file_path); } diff --git a/Userland/Libraries/LibDebug/DebugSession.cpp b/Userland/Libraries/LibDebug/DebugSession.cpp index de990e62209..9d3bd88e5a7 100644 --- a/Userland/Libraries/LibDebug/DebugSession.cpp +++ b/Userland/Libraries/LibDebug/DebugSession.cpp @@ -445,7 +445,7 @@ void DebugSession::update_loaded_libs() vm_entries.for_each([&](auto& entry) { // TODO: check that region is executable - auto vm_name = entry.as_object().get("name").as_string(); + auto vm_name = entry.as_object().get("name"sv).as_string(); auto object_path = get_path_to_object(vm_name); if (!object_path.has_value()) @@ -455,7 +455,7 @@ void DebugSession::update_loaded_libs() if (Core::File::looks_like_shared_library(lib_name)) lib_name = LexicalPath::basename(object_path.value()); - FlatPtr base_address = entry.as_object().get("address").to_addr(); + FlatPtr base_address = entry.as_object().get("address"sv).to_addr(); if (auto it = m_loaded_libraries.find(lib_name); it != m_loaded_libraries.end()) { // We expect the VM regions to be sorted by address. VERIFY(base_address >= it->value->base_address); diff --git a/Userland/Libraries/LibDesktop/AppFile.cpp b/Userland/Libraries/LibDesktop/AppFile.cpp index 6d9ae97c46a..1b7e0c99205 100644 --- a/Userland/Libraries/LibDesktop/AppFile.cpp +++ b/Userland/Libraries/LibDesktop/AppFile.cpp @@ -33,7 +33,7 @@ void AppFile::for_each(Function)> callback, StringVi return; while (di.has_next()) { auto name = di.next_path(); - if (!name.ends_with(".af")) + if (!name.ends_with(".af"sv)) continue; auto path = String::formatted("{}/{}", directory, name); auto af = AppFile::open(path); diff --git a/Userland/Libraries/LibDesktop/AppFile.h b/Userland/Libraries/LibDesktop/AppFile.h index a9f10da6fa9..cb393db6e28 100644 --- a/Userland/Libraries/LibDesktop/AppFile.h +++ b/Userland/Libraries/LibDesktop/AppFile.h @@ -15,7 +15,8 @@ namespace Desktop { class AppFile : public RefCounted { public: - static constexpr char const* APP_FILES_DIRECTORY = "/res/apps"; + static constexpr auto APP_FILES_DIRECTORY = "/res/apps"sv; + static NonnullRefPtr get_for_app(StringView app_name); static NonnullRefPtr open(StringView path); static void for_each(Function)>, StringView directory = APP_FILES_DIRECTORY); diff --git a/Userland/Libraries/LibDesktop/Launcher.cpp b/Userland/Libraries/LibDesktop/Launcher.cpp index 4cfd16beb43..e4add1ac9b6 100644 --- a/Userland/Libraries/LibDesktop/Launcher.cpp +++ b/Userland/Libraries/LibDesktop/Launcher.cpp @@ -19,9 +19,9 @@ auto Launcher::Details::from_details_str(String const& details_str) -> NonnullRe auto details = adopt_ref(*new Details); auto json = JsonValue::from_string(details_str).release_value_but_fixme_should_propagate_errors(); auto const& obj = json.as_object(); - details->executable = obj.get("executable").to_string(); - details->name = obj.get("name").to_string(); - if (auto type_value = obj.get_ptr("type")) { + details->executable = obj.get("executable"sv).to_string(); + details->name = obj.get("name"sv).to_string(); + if (auto type_value = obj.get_ptr("type"sv)) { auto type_str = type_value->to_string(); if (type_str == "app") details->launcher_type = LauncherType::Application; diff --git a/Userland/Libraries/LibELF/Core.h b/Userland/Libraries/LibELF/Core.h index eb29e568668..1f19ea688c2 100644 --- a/Userland/Libraries/LibELF/Core.h +++ b/Userland/Libraries/LibELF/Core.h @@ -61,9 +61,9 @@ struct [[gnu::packed]] MemoryRegionInfo { #ifndef KERNEL String object_name() const { - StringView memory_region_name { region_name }; - if (memory_region_name.contains("Loader.so")) - return "Loader.so"; + StringView memory_region_name { region_name, strlen(region_name) }; + if (memory_region_name.contains("Loader.so"sv)) + return "Loader.so"sv; auto maybe_colon_index = memory_region_name.find(':'); if (!maybe_colon_index.has_value()) return {}; diff --git a/Userland/Libraries/LibELF/DynamicLoader.cpp b/Userland/Libraries/LibELF/DynamicLoader.cpp index 6ea9ab82db8..956d5f9f584 100644 --- a/Userland/Libraries/LibELF/DynamicLoader.cpp +++ b/Userland/Libraries/LibELF/DynamicLoader.cpp @@ -397,9 +397,9 @@ void DynamicLoader::load_program_headers() StringBuilder builder; builder.append(m_filepath); if (region.is_executable()) - builder.append(": .text"); + builder.append(": .text"sv); else - builder.append(": .rodata"); + builder.append(": .rodata"sv); // Now we can map the text segment at the reserved address. auto* segment_base = (u8*)mmap_with_name( diff --git a/Userland/Libraries/LibELF/DynamicObject.cpp b/Userland/Libraries/LibELF/DynamicObject.cpp index 29471f65609..193c9c42303 100644 --- a/Userland/Libraries/LibELF/DynamicObject.cpp +++ b/Userland/Libraries/LibELF/DynamicObject.cpp @@ -41,7 +41,7 @@ void DynamicObject::dump() const { if constexpr (DYNAMIC_LOAD_DEBUG) { StringBuilder builder; - builder.append("\nd_tag tag_name value\n"); + builder.append("\nd_tag tag_name value\n"sv); size_t num_dynamic_sections = 0; for_each_dynamic_entry([&](DynamicObject::DynamicEntry const& entry) { diff --git a/Userland/Libraries/LibELF/Image.cpp b/Userland/Libraries/LibELF/Image.cpp index da79f41f656..d5d81b23e4f 100644 --- a/Userland/Libraries/LibELF/Image.cpp +++ b/Userland/Libraries/LibELF/Image.cpp @@ -60,7 +60,7 @@ void Image::dump() const return; } - dbgln(" type: {}", ELF::Image::object_file_type_to_string(header().e_type).value_or("(?)")); + dbgln(" type: {}", ELF::Image::object_file_type_to_string(header().e_type).value_or("(?)"sv)); dbgln(" machine: {}", header().e_machine); dbgln(" entry: {:x}", header().e_entry); dbgln(" shoff: {}", header().e_shoff); diff --git a/Userland/Libraries/LibGL/GLContext.cpp b/Userland/Libraries/LibGL/GLContext.cpp index 8fa80a2ecf0..3e87e7c584b 100644 --- a/Userland/Libraries/LibGL/GLContext.cpp +++ b/Userland/Libraries/LibGL/GLContext.cpp @@ -1216,10 +1216,10 @@ void GLContext::build_extension_string() // Ideally we would verify if the selected device adheres to the requested OpenGL context version before context creation // and refuse to create a context if it doesn't. if (m_device_info.supports_npot_textures) - extensions.append("GL_ARB_texture_non_power_of_two"); + extensions.append("GL_ARB_texture_non_power_of_two"sv); if (m_device_info.num_texture_units > 1) - extensions.append("GL_ARB_multitexture"); + extensions.append("GL_ARB_multitexture"sv); m_extensions = String::join(" ", extensions); } @@ -1227,7 +1227,7 @@ void GLContext::build_extension_string() NonnullOwnPtr create_context(Gfx::Bitmap& bitmap) { // FIXME: Make driver selectable. This is currently hardcoded to LibSoftGPU - auto driver = MUST(GPU::Driver::try_create("softgpu")); + auto driver = MUST(GPU::Driver::try_create("softgpu"sv)); auto device = MUST(driver->try_create_device(bitmap.size())); auto context = make(driver, move(device), bitmap); dbgln_if(GL_DEBUG, "GL::create_context({}) -> {:p}", bitmap.size(), context.ptr()); diff --git a/Userland/Libraries/LibGUI/AboutDialog.cpp b/Userland/Libraries/LibGUI/AboutDialog.cpp index 1d864333645..9bbbdfa83cb 100644 --- a/Userland/Libraries/LibGUI/AboutDialog.cpp +++ b/Userland/Libraries/LibGUI/AboutDialog.cpp @@ -36,7 +36,7 @@ AboutDialog::AboutDialog(StringView name, Gfx::Bitmap const* icon, Window* paren widget.layout()->set_spacing(0); auto& banner_image = widget.add(); - banner_image.load_from_file("/res/graphics/brand-banner.png"); + banner_image.load_from_file("/res/graphics/brand-banner.png"sv); auto& content_container = widget.add(); content_container.set_layout(); @@ -69,9 +69,9 @@ AboutDialog::AboutDialog(StringView name, Gfx::Bitmap const* icon, Window* paren make_label(m_name, true); // If we are displaying a dialog for an application, insert 'SerenityOS' below the application name if (m_name != "SerenityOS") - make_label("SerenityOS"); + make_label("SerenityOS"sv); make_label(m_version_string); - make_label("Copyright \xC2\xA9 the SerenityOS developers, 2018-2022"); + make_label("Copyright \xC2\xA9 the SerenityOS developers, 2018-2022"sv); right_container.layout()->add_spacer(); diff --git a/Userland/Libraries/LibGUI/AbstractTableView.cpp b/Userland/Libraries/LibGUI/AbstractTableView.cpp index ba9ff35060d..eba13fdbeb1 100644 --- a/Userland/Libraries/LibGUI/AbstractTableView.cpp +++ b/Userland/Libraries/LibGUI/AbstractTableView.cpp @@ -60,7 +60,7 @@ void AbstractTableView::auto_resize_column(int column) int header_width = m_column_header->font().width(model.column_name(column)); if (column == m_key_column && model.is_column_sortable(column)) - header_width += font().width(" \xE2\xAC\x86"); + header_width += font().width(" \xE2\xAC\x86"sv); int column_width = header_width; bool is_empty = true; @@ -99,7 +99,7 @@ void AbstractTableView::update_column_sizes() continue; int header_width = m_column_header->font().width(model.column_name(column)); if (column == m_key_column && model.is_column_sortable(column)) - header_width += font().width(" \xE2\xAC\x86"); // UPWARDS BLACK ARROW + header_width += font().width(" \xE2\xAC\x86"sv); // UPWARDS BLACK ARROW int column_width = header_width; for (int row = 0; row < row_count; ++row) { auto cell_data = model.index(row, column).data(); diff --git a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp index 743ce60a0e3..e1cea74089f 100644 --- a/Userland/Libraries/LibGUI/AbstractThemePreview.cpp +++ b/Userland/Libraries/LibGUI/AbstractThemePreview.cpp @@ -21,12 +21,12 @@ namespace GUI { AbstractThemePreview::AbstractThemePreview(Gfx::Palette const& preview_palette) : m_preview_palette(preview_palette) { - m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors(); - m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors(); + m_active_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv).release_value_but_fixme_should_propagate_errors(); + m_inactive_window_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv).release_value_but_fixme_should_propagate_errors(); - m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").release_value_but_fixme_should_propagate_errors(); - m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors(); - m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors(); + m_default_close_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"sv).release_value_but_fixme_should_propagate_errors(); + m_default_maximize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"sv).release_value_but_fixme_should_propagate_errors(); + m_default_minimize_bitmap = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"sv).release_value_but_fixme_should_propagate_errors(); VERIFY(m_active_window_icon); VERIFY(m_inactive_window_icon); diff --git a/Userland/Libraries/LibGUI/Application.cpp b/Userland/Libraries/LibGUI/Application.cpp index b9574e7f098..073cceab35b 100644 --- a/Userland/Libraries/LibGUI/Application.cpp +++ b/Userland/Libraries/LibGUI/Application.cpp @@ -28,7 +28,7 @@ public: { m_label->set_text(Gfx::parse_ampersand_string(tooltip)); int tooltip_width = m_label->effective_min_size().width().as_int() + 10; - int line_count = m_label->text().count("\n"); + int line_count = m_label->text().count("\n"sv); int glyph_height = m_label->font().glyph_height(); int tooltip_height = glyph_height * (1 + line_count) + ((glyph_height + 1) / 2) * line_count + 8; diff --git a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp index f2b82ac6f62..0d208f1598d 100644 --- a/Userland/Libraries/LibGUI/AutocompleteProvider.cpp +++ b/Userland/Libraries/LibGUI/AutocompleteProvider.cpp @@ -52,13 +52,13 @@ public: if (index.column() == Column::Icon) { if (suggestion.language == CodeComprehension::Language::Cpp) { if (!s_cpp_identifier_icon) { - s_cpp_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/cpp-identifier.png").release_value_but_fixme_should_propagate_errors(); + s_cpp_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/cpp-identifier.png"sv).release_value_but_fixme_should_propagate_errors(); } return *s_cpp_identifier_icon; } if (suggestion.language == CodeComprehension::Language::Unspecified) { if (!s_unspecified_identifier_icon) { - s_unspecified_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/unspecified-identifier.png").release_value_but_fixme_should_propagate_errors(); + s_unspecified_identifier_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/completion/unspecified-identifier.png"sv).release_value_but_fixme_should_propagate_errors(); } return *s_unspecified_identifier_icon; } diff --git a/Userland/Libraries/LibGUI/ColorPicker.cpp b/Userland/Libraries/LibGUI/ColorPicker.cpp index 2af591fde56..79aaa6ffbb0 100644 --- a/Userland/Libraries/LibGUI/ColorPicker.cpp +++ b/Userland/Libraries/LibGUI/ColorPicker.cpp @@ -186,7 +186,7 @@ ColorPicker::ColorPicker(Color color, Window* parent_window, String title) : Dialog(parent_window) , m_color(color) { - set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png").release_value_but_fixme_should_propagate_errors()); + set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/color-chooser.png"sv).release_value_but_fixme_should_propagate_errors()); set_title(title); set_resizable(false); resize(458, 326); diff --git a/Userland/Libraries/LibGUI/ColumnsView.cpp b/Userland/Libraries/LibGUI/ColumnsView.cpp index ce1cbef995c..afd04ca2014 100644 --- a/Userland/Libraries/LibGUI/ColumnsView.cpp +++ b/Userland/Libraries/LibGUI/ColumnsView.cpp @@ -23,7 +23,7 @@ static constexpr Gfx::CharacterBitmap s_arrow_bitmap { " ### " " ## " " # " - " ", + " "sv, 9, 9 }; diff --git a/Userland/Libraries/LibGUI/ComboBox.cpp b/Userland/Libraries/LibGUI/ComboBox.cpp index 4ec805d20b0..90b4f7f37b9 100644 --- a/Userland/Libraries/LibGUI/ComboBox.cpp +++ b/Userland/Libraries/LibGUI/ComboBox.cpp @@ -98,7 +98,7 @@ ComboBox::ComboBox() m_open_button = add