You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kvrocks.apache.org by ma...@apache.org on 2023/08/31 05:17:04 UTC
[kvrocks] branch unstable updated: Use `emplace` instead of `insert` for map (#1718)
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 <tw...@gmail.com>
AuthorDate: Thu Aug 31 14:16:59 2023 +0900
Use `emplace` instead of `insert` for map (#1718)
Co-authored-by: hulk <hu...@gmail.com>
---
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;
}