This is an automated email from the ASF dual-hosted git repository.

maplefu pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git


The following commit(s) were added to refs/heads/unstable by this push:
     new 23faf36b Use `emplace` instead of `insert` for map (#1718)
23faf36b is described below

commit 23faf36bc20b0b2d2816fc53bda94fdd3f280789
Author: Twice <[email protected]>
AuthorDate: Thu Aug 31 14:16:59 2023 +0900

    Use `emplace` instead of `insert` for map (#1718)
    
    Co-authored-by: hulk <[email protected]>
---
 src/server/worker.cc                      |  2 +-
 src/storage/table_properties_collector.cc | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/server/worker.cc b/src/server/worker.cc
index 22ae28d2..3383c407 100644
--- a/src/server/worker.cc
+++ b/src/server/worker.cc
@@ -315,7 +315,7 @@ Status Worker::AddConnection(redis::Connection *c) {
     return {Status::NotOK, "max number of clients reached"};
   }
 
-  conns_.insert(std::pair<int, redis::Connection *>(c->GetFD(), c));
+  conns_.emplace(c->GetFD(), c);
   uint64_t id = svr->GetClientID();
   c->SetID(id);
 
diff --git a/src/storage/table_properties_collector.cc 
b/src/storage/table_properties_collector.cc
index c414289e..df760617 100644
--- a/src/storage/table_properties_collector.cc
+++ b/src/storage/table_properties_collector.cc
@@ -60,17 +60,17 @@ rocksdb::Status CompactOnExpiredCollector::AddUserKey(const 
rocksdb::Slice &key,
 }
 
 rocksdb::Status 
CompactOnExpiredCollector::Finish(rocksdb::UserCollectedProperties *properties) 
{
-  properties->insert(std::pair<std::string, std::string>{"total_keys", 
std::to_string(total_keys_)});
-  properties->insert(std::pair<std::string, std::string>{"deleted_keys", 
std::to_string(deleted_keys_)});
-  properties->insert(std::pair<std::string, std::string>{"start_key", 
start_key_});
-  properties->insert(std::pair<std::string, std::string>{"stop_key", 
stop_key_});
+  properties->emplace("total_keys", std::to_string(total_keys_));
+  properties->emplace("deleted_keys", std::to_string(deleted_keys_));
+  properties->emplace("start_key", start_key_);
+  properties->emplace("stop_key", stop_key_);
   return rocksdb::Status::OK();
 }
 
 rocksdb::UserCollectedProperties 
CompactOnExpiredCollector::GetReadableProperties() const {
   rocksdb::UserCollectedProperties properties;
-  properties.insert(std::pair<std::string, std::string>{"total_keys", 
std::to_string(total_keys_)});
-  properties.insert(std::pair<std::string, std::string>{"deleted_keys", 
std::to_string(deleted_keys_)});
+  properties.emplace("total_keys", std::to_string(total_keys_));
+  properties.emplace("deleted_keys", std::to_string(deleted_keys_));
   return properties;
 }
 

Reply via email to