diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-04-08 16:20:31 -0700 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2021-04-08 16:34:22 -0700 |
commit | 9be43874343b0aa2221497830d0356eb4b7eecfa (patch) | |
tree | 469eda98cfa911eecaf573d434ef3c6e909c9de2 /llvm/lib/Support/Signposts.cpp | |
parent | bf12b711f9ec322fd7fabb6919d975665df32b29 (diff) | |
download | llvm-9be43874343b0aa2221497830d0356eb4b7eecfa.zip llvm-9be43874343b0aa2221497830d0356eb4b7eecfa.tar.gz llvm-9be43874343b0aa2221497830d0356eb4b7eecfa.tar.bz2 |
Support: Avoid unnecessary std::function for SignpostEmitterImpl::SignpostLog
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.
Differential Revision: https://reviews.llvm.org/D100154
Diffstat (limited to 'llvm/lib/Support/Signposts.cpp')
-rw-r--r-- | llvm/lib/Support/Signposts.cpp | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/llvm/lib/Support/Signposts.cpp b/llvm/lib/Support/Signposts.cpp index 80ef7d1..586f1db 100644 --- a/llvm/lib/Support/Signposts.cpp +++ b/llvm/lib/Support/Signposts.cpp @@ -29,15 +29,17 @@ os_log_t *LogCreator() { *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 @@ class SignpostEmitterImpl { } public: - SignpostEmitterImpl() : SignpostLog(LogCreator(), LogDeleter) {} + SignpostEmitterImpl() : SignpostLog(LogCreator()) {} bool isEnabled() const { if (SIGNPOSTS_AVAILABLE()) |