1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

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.
This commit is contained in:
Idan Horowitz 2021-09-11 01:04:08 +03:00
parent 6d2b003b6e
commit aba4c9579f

View file

@ -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();