]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Ok, now each xline will be in two places. The sorted vector and a map, each line...
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 29 Oct 2007 00:23:11 +0000 (00:23 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Mon, 29 Oct 2007 00:23:11 +0000 (00:23 +0000)
This allows for faster checking for simple existence of a line for removal/adding without O(n) lookups

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8420 e03df62e-2008-0410-955e-edbf42e46eb7

include/xline.h
src/xline.cpp

index 6e32944fef92581eb98fd9bcfe4c9c280ca5b0a9..711897e4deba899d497e783213aea344421a82df 100644 (file)
@@ -359,7 +359,7 @@ class CoreExport XLineManager
 
  public:
 
-       std::map<std::string, ELine *> elines;
+       std::map<char, std::map<std::string, ELine *> > lookup_lines;
 
        /** Constructor
         * @param Instance A pointer to the creator object
index f436d96922038bd69b981550bb1621d67deb6c49..bfa21b21d180cb9f9485dcece28a581664cbfb43 100644 (file)
@@ -205,10 +205,10 @@ bool XLineManager::AddELine(long duration, const char* source, const char* reaso
 
        active_lines.push_back(item);
        sort(active_lines.begin(), active_lines.end(),XLineManager::XSortComparison);
-       elines[hostmask] = item;
+       lookup_lines['E'][hostmask] = item;
 
        // XXX we really only need to check one line (the new one) - this is a bit wasteful!
-       CheckELines(ServerInstance, elines);
+       CheckELines(ServerInstance, lookup_lines['E']);
 
        return true;
 }
@@ -305,8 +305,8 @@ void ELine::Unset()
                User* u = (User*)(*u2);
                u->exempt = false;
        }
-       ServerInstance->XLines->elines.erase(this->identmask + std::string("@") + this->hostmask);
-       CheckELines(ServerInstance, ServerInstance->XLines->elines);
+       ServerInstance->XLines->lookup_lines['E'].erase(this->identmask + std::string("@") + this->hostmask);
+       CheckELines(ServerInstance, ServerInstance->XLines->lookup_lines['E']);
 }
 
 // returns a pointer to the reason if a nickname matches a qline, NULL if it didnt match
@@ -332,7 +332,7 @@ GLine* XLineManager::matches_gline(User* user)
 
 ELine* XLineManager::matches_exception(User* user)
 {
-       if (elines.empty())
+       if (lookup_lines['E'].empty())
                return NULL;
 
        for (std::vector<XLine*>::iterator i = active_lines.begin(); i != active_lines.end(); i++)