forked from OSchip/llvm-project
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
This commit is contained in:
parent
bf12b711f9
commit
9be4387434
|
@ -29,15 +29,17 @@ os_log_t *LogCreator() {
|
||||||
*X = os_log_create("org.llvm.signposts", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
|
*X = os_log_create("org.llvm.signposts", OS_LOG_CATEGORY_POINTS_OF_INTEREST);
|
||||||
return X;
|
return X;
|
||||||
}
|
}
|
||||||
void LogDeleter(os_log_t *X) {
|
struct LogDeleter {
|
||||||
os_release(*X);
|
void operator()(os_log_t *X) const {
|
||||||
delete X;
|
os_release(*X);
|
||||||
}
|
delete X;
|
||||||
|
}
|
||||||
|
};
|
||||||
} // end anonymous namespace
|
} // end anonymous namespace
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
class SignpostEmitterImpl {
|
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;
|
using LogTy = LogPtrTy::element_type;
|
||||||
|
|
||||||
LogPtrTy SignpostLog;
|
LogPtrTy SignpostLog;
|
||||||
|
@ -59,7 +61,7 @@ class SignpostEmitterImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
SignpostEmitterImpl() : SignpostLog(LogCreator(), LogDeleter) {}
|
SignpostEmitterImpl() : SignpostLog(LogCreator()) {}
|
||||||
|
|
||||||
bool isEnabled() const {
|
bool isEnabled() const {
|
||||||
if (SIGNPOSTS_AVAILABLE())
|
if (SIGNPOSTS_AVAILABLE())
|
||||||
|
|
Loading…
Reference in New Issue