From 25f70a5abbc2e3e38b8a67013f91c1ccea961aaa Mon Sep 17 00:00:00 2001 From: Yueh-Hsuan Chiang Date: Tue, 16 Dec 2014 17:10:23 -0800 Subject: [PATCH] Avoid unnecessary unlock and lock mutex when notifying events. Summary: Avoid unnecessary unlock and lock mutex when notifying events. Test Plan: ./listener_test Reviewers: igor Reviewed By: igor Subscribers: sdong, dhruba, leveldb Differential Revision: https://reviews.facebook.net/D30267 --- db/db_impl.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index a87d4d1476..3275165e88 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1112,6 +1112,9 @@ Status DBImpl::FlushMemTableToOutputFile( void DBImpl::NotifyOnFlushCompleted( ColumnFamilyData* cfd, uint64_t file_number, const MutableCFOptions& mutable_cf_options) { + if (cfd->ioptions()->listeners.size() == 0U) { + return; + } mutex_.AssertHeld(); if (shutting_down_.load(std::memory_order_acquire)) { return;