mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 06:18:07 +03:00
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:
parent
c1db56d68d
commit
6e1789bfff
@ -24,7 +24,7 @@ folly::Try<std::string> readFile(AbsolutePathPiece path, size_t num_bytes) {
|
|||||||
fmt::format(FMT_STRING("couldn't read {}"), path))};
|
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) {
|
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {
|
||||||
@ -66,7 +66,7 @@ folly::Try<std::vector<PathComponent>> getAllDirectoryEntryNames(
|
|||||||
for (const auto& entry : iter) {
|
for (const auto& entry : iter) {
|
||||||
direntNames.emplace_back(entry.path().filename().c_str());
|
direntNames.emplace_back(entry.path().filename().c_str());
|
||||||
}
|
}
|
||||||
return folly::Try{direntNames};
|
return folly::Try{std::move(direntNames)};
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#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))};
|
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) {
|
folly::Try<void> writeFile(AbsolutePathPiece path, folly::ByteRange data) {
|
||||||
|
Loading…
Reference in New Issue
Block a user