diff --git a/Tests/AK/TestFormat.cpp b/Tests/AK/TestFormat.cpp index 50ddde2f47..17814d79ac 100644 --- a/Tests/AK/TestFormat.cpp +++ b/Tests/AK/TestFormat.cpp @@ -39,9 +39,9 @@ TEST_CASE(reorder_format_arguments) EXPECT_EQ(String::formatted("{1}{0}", "a", "b"), "ba"); EXPECT_EQ(String::formatted("{0}{1}", "a", "b"), "ab"); // Compiletime check bypass: ignoring a passed argument. - EXPECT_EQ(String::formatted(StringView { "{0}{0}{0}" }, "a", "b"), "aaa"); + EXPECT_EQ(String::formatted("{0}{0}{0}"sv, "a", "b"), "aaa"); // Compiletime check bypass: ignoring a passed argument. - EXPECT_EQ(String::formatted(StringView { "{1}{}{0}" }, "a", "b", "c"), "baa"); + EXPECT_EQ(String::formatted("{1}{}{0}"sv, "a", "b", "c"), "baa"); } TEST_CASE(escape_braces) @@ -108,7 +108,7 @@ TEST_CASE(replacement_field) EXPECT_EQ(String::formatted("{:*>{1}}", 13, static_cast(10)), "********13"); EXPECT_EQ(String::formatted("{:*<{1}}", 7, 4), "7***"); // Compiletime check bypass: intentionally ignoring extra arguments - EXPECT_EQ(String::formatted(StringView { "{:{2}}" }, -5, 8, 16), " -5"); + EXPECT_EQ(String::formatted("{:{2}}"sv, -5, 8, 16), " -5"); EXPECT_EQ(String::formatted("{{{:*^{1}}}}", 1, 3), "{*1*}"); EXPECT_EQ(String::formatted("{:0{}}", 1, 3), "001"); } @@ -116,7 +116,7 @@ TEST_CASE(replacement_field) TEST_CASE(replacement_field_regression) { // FIXME: Compiletime check bypass: cannot parse '}}' correctly. - EXPECT_EQ(String::formatted(StringView { "{:{}}" }, "", static_cast(6)), " "); + EXPECT_EQ(String::formatted("{:{}}"sv, "", static_cast(6)), " "); } TEST_CASE(complex_string_specifiers) @@ -224,7 +224,7 @@ TEST_CASE(file_descriptor) Array buffer; const auto nread = fread(buffer.data(), 1, buffer.size(), file); - EXPECT_EQ(StringView { "Hello, World!\nfoobar\n" }, StringView { buffer.span().trim(nread) }); + EXPECT_EQ("Hello, World!\nfoobar\n"sv, StringView { buffer.span().trim(nread) }); fclose(file); } diff --git a/Tests/AK/TestGenericLexer.cpp b/Tests/AK/TestGenericLexer.cpp index 8b9a08cd1d..29089ec5d4 100644 --- a/Tests/AK/TestGenericLexer.cpp +++ b/Tests/AK/TestGenericLexer.cpp @@ -17,25 +17,25 @@ TEST_CASE(should_constexpr_construct_from_empty_string_view) TEST_CASE(should_construct_from_string_view) { - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(!sut.is_eof()); } TEST_CASE(should_constexpr_tell) { - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(sut.tell() == 0); } TEST_CASE(should_constexpr_tell_remaining) { - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(sut.tell_remaining() == 6); } TEST_CASE(should_constexpr_peek) { - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(sut.peek() == 'a'); static_assert(sut.peek(2) == 'c'); static_assert(sut.peek(100) == '\0'); @@ -43,16 +43,16 @@ TEST_CASE(should_constexpr_peek) TEST_CASE(should_constexpr_next_is) { - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(sut.next_is('a')); static_assert(sut.next_is("abc")); - static_assert(sut.next_is(StringView { "abc" })); + static_assert(sut.next_is("abc"sv)); } TEST_CASE(should_constexpr_retreat) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.consume(); sut.retreat(); return sut; @@ -63,7 +63,7 @@ TEST_CASE(should_constexpr_retreat) TEST_CASE(should_constexpr_consume_1) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.consume(); return sut; }(); @@ -73,7 +73,7 @@ TEST_CASE(should_constexpr_consume_1) TEST_CASE(should_constexpr_consume_specific_char) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.consume_specific('a'); return sut; }(); @@ -83,8 +83,8 @@ TEST_CASE(should_constexpr_consume_specific_char) TEST_CASE(should_constexpr_consume_specific_string_view) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); - sut.consume_specific(StringView { "ab" }); + GenericLexer sut("abcdef"sv); + sut.consume_specific("ab"sv); return sut; }(); static_assert(sut.peek() == 'c'); @@ -93,7 +93,7 @@ TEST_CASE(should_constexpr_consume_specific_string_view) TEST_CASE(should_constexpr_consume_specific_cstring) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.consume_specific("abcd"); return sut; }(); @@ -103,7 +103,7 @@ TEST_CASE(should_constexpr_consume_specific_cstring) TEST_CASE(should_constexpr_ignore_until) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.ignore_until('d'); return sut; }(); @@ -113,7 +113,7 @@ TEST_CASE(should_constexpr_ignore_until) TEST_CASE(should_constexpr_ignore_until_cstring) { constexpr auto sut = [] { - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.ignore_until("cde"); return sut; }(); @@ -125,7 +125,7 @@ TEST_CASE(should_constexpr_next_is_pred) constexpr auto pred = [](auto c) { return c == 'a'; }; - constexpr GenericLexer sut(StringView { "abcdef" }); + constexpr GenericLexer sut("abcdef"sv); static_assert(sut.next_is(pred)); } @@ -136,7 +136,7 @@ TEST_CASE(should_constexpr_ignore_while_pred) return c == 'a'; }; - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.ignore_while(pred); return sut; }(); @@ -150,7 +150,7 @@ TEST_CASE(should_constexpr_ignore_until_pred) return c == 'c'; }; - GenericLexer sut(StringView { "abcdef" }); + GenericLexer sut("abcdef"sv); sut.ignore_until(pred); return sut; }(); diff --git a/Userland/Applications/Calculator/Keypad.cpp b/Userland/Applications/Calculator/Keypad.cpp index 2991c82632..243a895f11 100644 --- a/Userland/Applications/Calculator/Keypad.cpp +++ b/Userland/Applications/Calculator/Keypad.cpp @@ -158,7 +158,7 @@ String Keypad::to_string() const if (m_frac_length > 0) { // FIXME: This disables the compiletime format string check since we can't parse '}}' here correctly. // remove the 'StringView { }' when that's fixed. - builder.appendff(StringView { "{:0{}}" }, m_frac_value.value(), m_frac_length); + builder.appendff("{:0{}}"sv, m_frac_value.value(), m_frac_length); } return builder.to_string(); diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index fc40dca2ba..e912866a79 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -160,7 +160,7 @@ void HackStudioWidget::update_actions() auto widget = m_action_tab_widget->active_widget(); if (!widget) return false; - if (StringView { "TerminalWrapper" } != widget->class_name()) + if ("TerminalWrapper"sv != widget->class_name()) return false; if (!reinterpret_cast(widget)->user_spawned()) return false; diff --git a/Userland/DevTools/Playground/GMLAutocompleteProvider.cpp b/Userland/DevTools/Playground/GMLAutocompleteProvider.cpp index 2d88ea5da0..150f619b92 100644 --- a/Userland/DevTools/Playground/GMLAutocompleteProvider.cpp +++ b/Userland/DevTools/Playground/GMLAutocompleteProvider.cpp @@ -149,7 +149,7 @@ void GMLAutocompleteProvider::provide_completions(Function)> identifier_entries.empend(it.key, identifier_string.length()); } } - if (can_have_declared_layout(class_names.last()) && StringView { "layout" }.starts_with(identifier_string)) + if (can_have_declared_layout(class_names.last()) && "layout"sv.starts_with(identifier_string)) identifier_entries.empend("layout", identifier_string.length()); // No need to suggest anything if it's already completely typed out! if (identifier_entries.size() == 1 && identifier_entries.first().completion == identifier_string) diff --git a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp index b1c95bbd00..8bf878ad86 100644 --- a/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp +++ b/Userland/Libraries/LibTest/JavaScriptTestRunnerMain.cpp @@ -98,9 +98,9 @@ int main(int argc, char** argv) .long_name = "show-progress", .short_name = 'p', .accept_value = [&](auto* str) { - if (StringView { "true" } == str) + if ("true"sv == str) print_progress = true; - else if (StringView { "false" } == str) + else if ("false"sv == str) print_progress = false; else return false; diff --git a/Userland/Shell/main.cpp b/Userland/Shell/main.cpp index 8c07b7ecc4..bbc11e28db 100644 --- a/Userland/Shell/main.cpp +++ b/Userland/Shell/main.cpp @@ -138,7 +138,7 @@ int main(int argc, char** argv) } } - auto execute_file = file_to_read_from && StringView { "-" } != file_to_read_from; + auto execute_file = file_to_read_from && "-"sv != file_to_read_from; attempt_interactive = !execute_file; initialize(); diff --git a/Userland/Utilities/expr.cpp b/Userland/Utilities/expr.cpp index 6445f3876a..b2e9de5ce6 100644 --- a/Userland/Utilities/expr.cpp +++ b/Userland/Utilities/expr.cpp @@ -577,7 +577,7 @@ int main(int argc, char** argv) return 1; } - if ((argc == 2 && StringView { "--help" } == argv[1]) || argc == 1) + if ((argc == 2 && "--help"sv == argv[1]) || argc == 1) print_help_and_exit(); Queue args; diff --git a/Userland/Utilities/grep.cpp b/Userland/Utilities/grep.cpp index ba3d9bb1d7..3210412f61 100644 --- a/Userland/Utilities/grep.cpp +++ b/Userland/Utilities/grep.cpp @@ -59,11 +59,11 @@ int main(int argc, char** argv) .help_string = "Action to take for binary files ([binary], text, skip)", .long_name = "binary-mode", .accept_value = [&](auto* str) { - if (StringView { "text" } == str) + if ("text"sv == str) binary_mode = BinaryFileMode::Text; - else if (StringView { "binary" } == str) + else if ("binary"sv == str) binary_mode = BinaryFileMode::Binary; - else if (StringView { "skip" } == str) + else if ("skip"sv == str) binary_mode = BinaryFileMode::Skip; else return false; diff --git a/Userland/Utilities/run-tests.cpp b/Userland/Utilities/run-tests.cpp index ba987c3736..da9cfb6c27 100644 --- a/Userland/Utilities/run-tests.cpp +++ b/Userland/Utilities/run-tests.cpp @@ -276,9 +276,9 @@ int main(int argc, char** argv) .long_name = "show-progress", .short_name = 'p', .accept_value = [&](auto* str) { - if (StringView { "true" } == str) + if ("true"sv == str) print_progress = true; - else if (StringView { "false" } == str) + else if ("false"sv == str) print_progress = false; else return false; diff --git a/Userland/Utilities/xargs.cpp b/Userland/Utilities/xargs.cpp index 73a53be370..2e6b7d138a 100644 --- a/Userland/Utilities/xargs.cpp +++ b/Userland/Utilities/xargs.cpp @@ -89,7 +89,7 @@ int main(int argc, char** argv) FILE* fp = stdin; bool is_stdin = true; - if (StringView { "-" } != file_to_read) { + if ("-"sv != file_to_read) { // A file was specified, try to open it. fp = fopen(file_to_read, "re"); if (!fp) {