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
This commit is contained in:
Chad Austin 2022-11-09 18:38:58 -08:00 committed by Facebook GitHub Bot
parent c1db56d68d
commit 6e1789bfff

View File

@ -24,7 +24,7 @@ folly::Try<std::string> readFile(AbsolutePathPiece path, size_t num_bytes) {
fmt::format(FMT_STRING("couldn't read {}"), path))};
}
return folly::Try{ret};
return folly::Try{std::move(ret)};
}
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {
@ -66,7 +66,7 @@ folly::Try<std::vector<PathComponent>> getAllDirectoryEntryNames(
for (const auto& entry : iter) {
direntNames.emplace_back(entry.path().filename().c_str());
}
return folly::Try{direntNames};
return folly::Try{std::move(direntNames)};
}
#else
@ -178,7 +178,7 @@ folly::Try<std::string> readFile(AbsolutePathPiece path, size_t num_bytes) {
GetLastError(), fmt::format(FMT_STRING("couldn't read {}"), path))};
}
return folly::Try{ret};
return folly::Try{std::move(ret)};
}
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {