From 1a3fa2d88b07fc2d0418fbcc9f1d2cf085498b98 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 13 Feb 2022 12:48:27 +0100 Subject: [PATCH] LibJS: Make Parser::ScopePusher::has_declaration() take FlyString Everyone who calls this already has a FlyString, so we were doing *way* more work by pessimizing it to a StringView. This gives a ~2% speedup when parsing the largest Discord JS file. --- Userland/Libraries/LibJS/Parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/Libraries/LibJS/Parser.cpp b/Userland/Libraries/LibJS/Parser.cpp index 89324db44b..cb746982a1 100644 --- a/Userland/Libraries/LibJS/Parser.cpp +++ b/Userland/Libraries/LibJS/Parser.cpp @@ -190,7 +190,7 @@ public: ScopePusher* parent_scope() { return m_parent_scope; } ScopePusher const* parent_scope() const { return m_parent_scope; } - [[nodiscard]] bool has_declaration(StringView name) const + [[nodiscard]] bool has_declaration(FlyString const& name) const { return m_lexical_names.contains(name) || m_var_names.contains(name) || !m_functions_to_hoist.find_if([&name](auto& function) { return function->name() == name; }).is_end(); }