summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2020-04-03 16:11:46 +0200
committerMax Kellermann <max@musicpd.org>2020-04-03 16:12:51 +0200
commita269fc988b00b0a416d9edb25bde4211e2a15f54 (patch)
tree8865c6f2cbdf8d633b0dfd140e0a54dca933899e /src
parent915c48f748010c03ce400bdcb5484dbd7dfb612f (diff)
fs/Charset: enable RVO in FixSeparators()
Diffstat (limited to 'src')
-rw-r--r--src/fs/Charset.cxx12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/fs/Charset.cxx b/src/fs/Charset.cxx
index 0a89111e5..6b4ca9f0a 100644
--- a/src/fs/Charset.cxx
+++ b/src/fs/Charset.cxx
@@ -74,19 +74,21 @@ GetFSCharset() noexcept
#endif
}
-static inline PathTraitsUTF8::string &&
-FixSeparators(PathTraitsUTF8::string &&s)
+static inline PathTraitsUTF8::string
+FixSeparators(const PathTraitsUTF8::string_view _s)
{
// For whatever reason GCC can't convert constexpr to value reference.
// This leads to link errors when passing separators directly.
auto to = PathTraitsUTF8::SEPARATOR;
decltype(to) from = PathTraitsFS::SEPARATOR;
+ PathTraitsUTF8::string s(_s);
+
if (from != to)
/* convert backslash to slash on WIN32 */
std::replace(s.begin(), s.end(), from, to);
- return std::move(s);
+ return s;
}
PathTraitsUTF8::string
@@ -99,7 +101,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs)
#ifdef _WIN32
const auto buffer = WideCharToMultiByte(CP_UTF8, path_fs);
- return FixSeparators(PathTraitsUTF8::string(buffer));
+ return FixSeparators(buffer);
#else
#ifdef HAVE_FS_CHARSET
if (fs_converter == nullptr)
@@ -108,7 +110,7 @@ PathToUTF8(PathTraitsFS::const_pointer path_fs)
#ifdef HAVE_FS_CHARSET
const auto buffer = fs_converter->ToUTF8(path_fs);
- return FixSeparators(PathTraitsUTF8::string(buffer));
+ return FixSeparators(buffer);
#endif
#endif
}