Skip to content

Commit 6e1789b

Browse files
chadaustinfacebook-github-bot
authored andcommitted
remove unnecessary copies from FileUtils
Summary: RVO only works when the local and the return type are exact matches. Here, we're invoking the constructor, so we need to std::move. Reviewed By: xavierd Differential Revision: D41097721 fbshipit-source-id: 52e4425a960ce0aa8ae59a827ddde4e9b58a7f92
1 parent c1db56d commit 6e1789b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

eden/fs/utils/FileUtils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ folly::Try<std::string> readFile(AbsolutePathPiece path, size_t num_bytes) {
2424
fmt::format(FMT_STRING("couldn't read {}"), path))};
2525
}
2626

27-
return folly::Try{ret};
27+
return folly::Try{std::move(ret)};
2828
}
2929

3030
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {
@@ -66,7 +66,7 @@ folly::Try<std::vector<PathComponent>> getAllDirectoryEntryNames(
6666
for (const auto& entry : iter) {
6767
direntNames.emplace_back(entry.path().filename().c_str());
6868
}
69-
return folly::Try{direntNames};
69+
return folly::Try{std::move(direntNames)};
7070
}
7171

7272
#else
@@ -178,7 +178,7 @@ folly::Try<std::string> readFile(AbsolutePathPiece path, size_t num_bytes) {
178178
GetLastError(), fmt::format(FMT_STRING("couldn't read {}"), path))};
179179
}
180180

181-
return folly::Try{ret};
181+
return folly::Try{std::move(ret)};
182182
}
183183

184184
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {

0 commit comments

Comments
 (0)