From 69b64a6b0480696215b7faa1e92180206b9f221a Mon Sep 17 00:00:00 2001 From: Rodrigo Tobar Date: Tue, 28 Sep 2021 12:02:32 +0800 Subject: [PATCH] AK: Accept StringView in LexicalPath::join The first argument for LexicalPath::join was a String const&, which resulted in an unnecessary memory copy when invoked with a StringView. Changing the type of the parameter to StringView avoids the extra cost. This was noticed while working on #10230. --- AK/LexicalPath.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AK/LexicalPath.h b/AK/LexicalPath.h index 3a36f769aa..a14795d6bf 100644 --- a/AK/LexicalPath.h +++ b/AK/LexicalPath.h @@ -36,7 +36,7 @@ public: [[nodiscard]] static String relative_path(StringView const& absolute_path, StringView const& prefix); template - [[nodiscard]] static LexicalPath join(String const& first, S&&... rest) + [[nodiscard]] static LexicalPath join(StringView first, S&&... rest) { StringBuilder builder; builder.append(first);