[PATCH] D100154: Support: Avoid unnecessary std::function for SignpostEmitterImpl::SignpostLog
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 8 16:21:43 PDT 2021
dexonsmith created this revision.
dexonsmith added reviewers: dsanders, bogner.
Herald added a subscriber: hiraditya.
dexonsmith requested review of this revision.
Herald added a project: LLVM.
The destructor for SignPostEmitterImpl::SignpostLog is known statically. Avoid
the unnecessary vtable indirection through std::function in the std::unique_ptr
by turning LogDeleter into a struct. No real functionality change here.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D100154
Files:
llvm/lib/Support/Signposts.cpp
Index: llvm/lib/Support/Signposts.cpp
===================================================================
--- llvm/lib/Support/Signposts.cpp
+++ llvm/lib/Support/Signposts.cpp
@@ -29,15 +29,17 @@
*X = os_log_create("org.llvm.signposts", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
return X;
}
-void LogDeleter(os_log_t *X) {
- os_release(*X);
- delete X;
-}
+struct LogDeleter {
+ void operator()(os_log_t *X) const {
+ os_release(*X);
+ delete X;
+ }
+};
} // end anonymous namespace
namespace llvm {
class SignpostEmitterImpl {
- using LogPtrTy = std::unique_ptr<os_log_t, std::function<void(os_log_t *)>>;
+ using LogPtrTy = std::unique_ptr<os_log_t, LogDeleter>;
using LogTy = LogPtrTy::element_type;
LogPtrTy SignpostLog;
@@ -59,7 +61,7 @@
}
public:
- SignpostEmitterImpl() : SignpostLog(LogCreator(), LogDeleter) {}
+ SignpostEmitterImpl() : SignpostLog(LogCreator()) {}
bool isEnabled() const {
if (SIGNPOSTS_AVAILABLE())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D100154.336258.patch
Type: text/x-patch
Size: 972 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210408/36554162/attachment.bin>
More information about the llvm-commits
mailing list