Skip to content

Commit fa2bac0

Browse files
author
MarcoFalke
committed
refactor: Avoid copy/move in fs.h
The operator accepts a const& reference, so no copy or move is needed. See https://en.cppreference.com/w/cpp/filesystem/path/append
1 parent faea302 commit fa2bac0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/util/fs.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class path : public std::filesystem::path
3535
// Allow path objects arguments for compatibility.
3636
path(std::filesystem::path path) : std::filesystem::path::path(std::move(path)) {}
3737
path& operator=(std::filesystem::path path) { std::filesystem::path::operator=(std::move(path)); return *this; }
38-
path& operator/=(std::filesystem::path path) { std::filesystem::path::operator/=(path); return *this; }
38+
path& operator/=(const std::filesystem::path& path) { std::filesystem::path::operator/=(path); return *this; }
3939

4040
// Allow literal string arguments, which are safe as long as the literals are ASCII.
4141
path(const char* c) : std::filesystem::path(c) {}
@@ -97,9 +97,9 @@ static inline auto quoted(const std::string& s)
9797
}
9898

9999
// Allow safe path append operations.
100-
static inline path operator/(path p1, path p2)
100+
static inline path operator/(path p1, const path& p2)
101101
{
102-
p1 /= std::move(p2);
102+
p1 /= p2;
103103
return p1;
104104
}
105105
static inline path operator/(path p1, const char* p2)

0 commit comments

Comments
 (0)