浏览代码

Userland: Prefer `_short_string` over `String::from_utf8_short_string`

This user-defined literal is a strictly equivalent but shorter alias to
`String::from_utf8_short_string`.
Lucas CHOLLET 1 年之前
父节点
当前提交
a5edc9cdfc

+ 1 - 1
Userland/Applications/DisplaySettings/BackgroundSettingsWidget.cpp

@@ -60,7 +60,7 @@ ErrorOr<void> BackgroundSettingsWidget::create_frame()
     m_wallpaper_view->set_model(GUI::FileSystemModel::create("/res/wallpapers"));
     m_wallpaper_view->set_model(GUI::FileSystemModel::create("/res/wallpapers"));
     m_wallpaper_view->set_model_column(GUI::FileSystemModel::Column::Name);
     m_wallpaper_view->set_model_column(GUI::FileSystemModel::Column::Name);
     m_wallpaper_view->on_selection_change = [this] {
     m_wallpaper_view->on_selection_change = [this] {
-        String path = String::from_utf8_short_string(""sv);
+        String path;
         if (!m_wallpaper_view->selection().is_empty()) {
         if (!m_wallpaper_view->selection().is_empty()) {
             auto index = m_wallpaper_view->selection().first();
             auto index = m_wallpaper_view->selection().first();
             auto path_or_error = String::from_deprecated_string(static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->full_path(index));
             auto path_or_error = String::from_deprecated_string(static_cast<GUI::FileSystemModel*>(m_wallpaper_view->model())->full_path(index));

+ 1 - 1
Userland/Applications/Spreadsheet/HelpWindow.cpp

@@ -123,7 +123,7 @@ HelpWindow::HelpWindow(GUI::Window* parent)
 
 
             widget->add_sheet(sheet.release_nonnull());
             widget->add_sheet(sheet.release_nonnull());
             window->show();
             window->show();
-        } else if (url.host() == String::from_utf8_short_string("doc"sv)) {
+        } else if (url.host() == "doc"_short_string) {
             auto entry = LexicalPath::basename(url.serialize_path());
             auto entry = LexicalPath::basename(url.serialize_path());
             m_webview->load(URL::create_with_data("text/html"sv, render(entry)));
             m_webview->load(URL::create_with_data("text/html"sv, render(entry)));
         } else {
         } else {

+ 2 - 2
Userland/Applications/Spreadsheet/Spreadsheet.cpp

@@ -264,7 +264,7 @@ Optional<Position> Sheet::position_from_url(const URL& url) const
         return {};
         return {};
     }
     }
 
 
-    if (url.scheme() != "spreadsheet" || url.host() != String::from_utf8_short_string("cell"sv)) {
+    if (url.scheme() != "spreadsheet" || url.host() != "cell"_short_string) {
         dbgln("Bad url: {}", url.to_deprecated_string());
         dbgln("Bad url: {}", url.to_deprecated_string());
         return {};
         return {};
     }
     }
@@ -757,7 +757,7 @@ URL Position::to_url(Sheet const& sheet) const
 {
 {
     URL url;
     URL url;
     url.set_scheme("spreadsheet");
     url.set_scheme("spreadsheet");
-    url.set_host(String::from_utf8_short_string("cell"sv));
+    url.set_host("cell"_short_string);
     url.set_paths({ DeprecatedString::number(getpid()) });
     url.set_paths({ DeprecatedString::number(getpid()) });
     url.set_fragment(to_cell_identifier(sheet));
     url.set_fragment(to_cell_identifier(sheet));
     return url;
     return url;

+ 1 - 1
Userland/Libraries/LibManual/Node.cpp

@@ -82,7 +82,7 @@ ErrorOr<NonnullRefPtr<PageNode const>> Node::try_create_from_query(Vector<String
 
 
 ErrorOr<NonnullRefPtr<Node const>> Node::try_find_from_help_url(URL const& url)
 ErrorOr<NonnullRefPtr<Node const>> Node::try_find_from_help_url(URL const& url)
 {
 {
-    if (url.host() != String::from_utf8_short_string("man"sv))
+    if (url.host() != "man"_short_string)
         return Error::from_string_view("Bad help operation"sv);
         return Error::from_string_view("Bad help operation"sv);
     if (url.path_segment_count() < 2)
     if (url.path_segment_count() < 2)
         return Error::from_string_view("Bad help page URL"sv);
         return Error::from_string_view("Bad help page URL"sv);

+ 1 - 1
Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp

@@ -1142,7 +1142,7 @@ WebIDL::ExceptionOr<void> BrowsingContext::navigate(
         } else {
         } else {
             // Otherwise let navigation id be the result of generating a random UUID. [UUID]
             // Otherwise let navigation id be the result of generating a random UUID. [UUID]
             // FIXME: Generate a UUID.
             // FIXME: Generate a UUID.
-            navigation_id = String::from_utf8_short_string("FIXME"sv);
+            navigation_id = "FIXME"_short_string;
         }
         }
     }
     }
 
 

+ 1 - 1
Userland/Utilities/markdown-check.cpp

@@ -191,7 +191,7 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
             return RecursionDecision::Recurse;
             return RecursionDecision::Recurse;
         }
         }
         if (url.scheme() == "help") {
         if (url.scheme() == "help") {
-            if (url.host() != String::from_utf8_short_string("man"sv)) {
+            if (url.host() != "man"_short_string) {
                 warnln("help:// URL without 'man': {}", href);
                 warnln("help:// URL without 'man': {}", href);
                 m_has_invalid_link = true;
                 m_has_invalid_link = true;
                 return RecursionDecision::Recurse;
                 return RecursionDecision::Recurse;

+ 1 - 1
Userland/Utilities/netstat.cpp

@@ -138,7 +138,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
 
 
     auto get_formatted_user = [&](i32 uid) -> ErrorOr<String> {
     auto get_formatted_user = [&](i32 uid) -> ErrorOr<String> {
         if (uid == -1)
         if (uid == -1)
-            return String::from_utf8_short_string("-"sv);
+            return "-"_short_string;
 
 
         return String::number(uid);
         return String::number(uid);
     };
     };