diff options
author | attilamolnar <attilamolnar@hush.com> | 2012-10-01 00:50:08 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-04-10 19:27:24 +0200 |
commit | 239a3bb0f86d2bb431e7d450c992ad7edfd584d7 (patch) | |
tree | 8a681b1c3237880592566769d6461d41da9fb1fe | |
parent | c5d1a7843ed016c374b21242fccaca47e04b5a37 (diff) |
BanCache: Do one hash lookup in BanCacheManager::AddHit()
-rw-r--r-- | src/bancache.cpp | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/src/bancache.cpp b/src/bancache.cpp index 72f8728d3..a797335d1 100644 --- a/src/bancache.cpp +++ b/src/bancache.cpp @@ -25,14 +25,11 @@ BanCacheHit *BanCacheManager::AddHit(const std::string &ip, const std::string &type, const std::string &reason, time_t seconds) { - BanCacheHit *b; - - if (this->BanHash->find(ip) != this->BanHash->end()) // can't have two cache entries on the same IP, sorry.. + BanCacheHit*& b = (*BanHash)[ip]; + if (b != NULL) // can't have two cache entries on the same IP, sorry.. return NULL; - b = new BanCacheHit(ip, type, reason, (seconds ? seconds : 86400)); - - this->BanHash->insert(std::make_pair(ip, b)); + b = new BanCacheHit(type, reason, (seconds ? seconds : 86400)); return b; } |