]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
BanCache: Do one hash lookup in BanCacheManager::AddHit()
authorattilamolnar <attilamolnar@hush.com>
Sun, 30 Sep 2012 22:50:08 +0000 (00:50 +0200)
committerattilamolnar <attilamolnar@hush.com>
Wed, 10 Apr 2013 17:27:24 +0000 (19:27 +0200)
src/bancache.cpp

index 72f8728d3c2c10c8b4e488626a4bb74c497b0e3f..a797335d1f779fa05ec57efa2ca4fccce072d356 100644 (file)
 
 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;
 }