diff options
| author | Ilya Biryukov <ibiryukov@google.com> | 2019-09-18 08:31:28 +0000 |
|---|---|---|
| committer | Ilya Biryukov <ibiryukov@google.com> | 2019-09-18 08:31:28 +0000 |
| commit | edd5dfcd890dad921bb0c0edb1551597bd6124d7 (patch) | |
| tree | 36863eecc363735690fe4a50269756e5dd6bdac8 | |
| parent | 93e1f73b6b2dc751a27568da5797cc2ba8436385 (diff) | |
| download | bcm5719-llvm-edd5dfcd890dad921bb0c0edb1551597bd6124d7.tar.gz bcm5719-llvm-edd5dfcd890dad921bb0c0edb1551597bd6124d7.zip | |
[Support] Replace function with function_ref in writeFileAtomically. NFC
Summary:
The latter is slightly more efficient and communicates the intent of the
API: writeFileAtomically does not own or copy the callback, it merely
calls it at some point.
Reviewers: jkorous
Reviewed By: jkorous
Subscribers: hiraditya, dexonsmith, jfb, llvm-commits, cfe-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67584
llvm-svn: 372201
| -rw-r--r-- | llvm/include/llvm/Support/FileUtilities.h | 7 | ||||
| -rw-r--r-- | llvm/lib/Support/FileUtilities.cpp | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/llvm/include/llvm/Support/FileUtilities.h b/llvm/include/llvm/Support/FileUtilities.h index 04efdced32a..d661c5cbc03 100644 --- a/llvm/include/llvm/Support/FileUtilities.h +++ b/llvm/include/llvm/Support/FileUtilities.h @@ -14,6 +14,7 @@ #ifndef LLVM_SUPPORT_FILEUTILITIES_H #define LLVM_SUPPORT_FILEUTILITIES_H +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" @@ -107,9 +108,9 @@ namespace llvm { llvm::Error writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, StringRef Buffer); - llvm::Error - writeFileAtomically(StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer); + llvm::Error writeFileAtomically( + StringRef TempPathModel, StringRef FinalPath, + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer); } // End llvm namespace #endif diff --git a/llvm/lib/Support/FileUtilities.cpp b/llvm/lib/Support/FileUtilities.cpp index d11fbb54dc0..3d862f5f09e 100644 --- a/llvm/lib/Support/FileUtilities.cpp +++ b/llvm/lib/Support/FileUtilities.cpp @@ -296,7 +296,7 @@ llvm::Error llvm::writeFileAtomically(StringRef TempPathModel, llvm::Error llvm::writeFileAtomically( StringRef TempPathModel, StringRef FinalPath, - std::function<llvm::Error(llvm::raw_ostream &)> Writer) { + llvm::function_ref<llvm::Error(llvm::raw_ostream &)> Writer) { SmallString<128> GeneratedUniqPath; int TempFD; if (sys::fs::createUniqueFile(TempPathModel.str(), TempFD, |

