Selaa lähdekoodia

Browser: Use String::count instead of String::replace(X, X, true)

There's no need to create a new String just to count the amount of
occurrences of a substring.
Idan Horowitz 3 vuotta sitten
vanhempi
commit
aba4c9579f
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      Userland/Applications/Browser/BrowserWindow.cpp

+ 1 - 1
Userland/Applications/Browser/BrowserWindow.cpp

@@ -280,7 +280,7 @@ void BrowserWindow::build_menus()
             return;
         }
 
-        int argument_count = search_engine.replace("{}", "{}", true);
+        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);
             m_disable_search_engine_action->activate();