From b2ba87808970daeaf3cbef8cfd27fde0dab24934 Mon Sep 17 00:00:00 2001
From: Rye Mutt <rye@alchemyviewer.org>
Date: Wed, 23 Mar 2022 04:41:29 -0400
Subject: [PATCH] Optimize directory path building with string_view

---
 indra/llfilesystem/lldir.cpp | 8 ++++----
 indra/llfilesystem/lldir.h   | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/indra/llfilesystem/lldir.cpp b/indra/llfilesystem/lldir.cpp
index 1820543b05b..07456f1c574 100644
--- a/indra/llfilesystem/lldir.cpp
+++ b/indra/llfilesystem/lldir.cpp
@@ -1108,20 +1108,20 @@ void LLDir::dumpCurrentDirectories(LLError::ELevel level)
 	LL_VLOGS(level, "AppInit", "Directories") << "  UserSkinDir:           " << getUserSkinDir() << LL_ENDL;
 }
 
-void LLDir::append(std::string& destpath, const std::string& name) const
+void LLDir::append(std::string& destpath, std::string_view name) const
 {
 	// Delegate question of whether we need a separator to helper method.
 	SepOff sepoff(needSep(destpath, name));
 	if (sepoff.first)               // do we need a separator?
 	{
-		destpath += mDirDelimiter;
+		destpath.append(mDirDelimiter);
 	}
 	// If destpath ends with a separator, AND name starts with one, skip
 	// name's leading separator.
-	destpath += name.substr(sepoff.second);
+	destpath.append(name.substr(sepoff.second));
 }
 
-LLDir::SepOff LLDir::needSep(const std::string& path, const std::string& name) const
+LLDir::SepOff LLDir::needSep(std::string_view path, std::string_view name) const
 {
 	if (path.empty() || name.empty())
 	{
diff --git a/indra/llfilesystem/lldir.h b/indra/llfilesystem/lldir.h
index c32086ca027..acbd0ff0e2f 100644
--- a/indra/llfilesystem/lldir.h
+++ b/indra/llfilesystem/lldir.h
@@ -201,11 +201,11 @@ class LLDir
 
 	/// Append specified @a name to @a destpath, separated by getDirDelimiter()
 	/// if both are non-empty.
-	void append(std::string& destpath, const std::string& name) const;
+	void append(std::string& destpath, std::string_view name) const;
 	/// Variadic form: append @a name0 and @a name1 and arbitrary other @a
 	/// names to @a destpath, separated by getDirDelimiter() as needed.
 	template <typename... NAMES>
-	void append(std::string& destpath, const std::string& name0, const std::string& name1,
+	void append(std::string& destpath, std::string_view name0, std::string_view name1,
 				const NAMES& ... names) const
 	{
 		// In a typical recursion case, we'd accept (destpath, name0, names).
@@ -230,7 +230,7 @@ class LLDir
 protected:
 	// Does an add() or append() call need a directory delimiter?
 	typedef std::pair<bool, unsigned short> SepOff;
-	SepOff needSep(const std::string& path, const std::string& name) const;
+	SepOff needSep(std::string_view path, std::string_view name) const;
 	// build mSearchSkinDirs without adding duplicates
 	void addSearchSkinDir(const std::string& skindir);
 
-- 
GitLab