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);
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue