]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Faster CullItem/CullList using strdup rather than copying a std::string
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 10 Mar 2006 12:13:19 +0000 (12:13 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 10 Mar 2006 12:13:19 +0000 (12:13 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3626 e03df62e-2008-0410-955e-edbf42e46eb7

include/cull_list.h
src/cull_list.cpp
src/svn-rev.sh

index ca7189f4ce9b0603026cc27098e6c57efa48fbb4..df91e2eca9180e20161973e4c46df9c4aa284f6a 100644 (file)
@@ -42,7 +42,7 @@ class CullItem
         userrec* user;
        /** Holds the quit reason to use for this user.
         */
-        std::string reason;
+       char* reason;
  public:
        /** Constrcutor.
         * Initializes the CullItem with a user pointer
@@ -52,12 +52,15 @@ class CullItem
         */
         CullItem(userrec* u, std::string &r);
        CullItem(userrec* u, const char* r);
+
+       ~CullItem();
+
        /** Returns a pointer to the user
         */
         userrec* GetUser();
        /** Returns the user's quit reason
         */
-        std::string GetReason();
+       const char* GetReason();
 };
 
 /** The CullList class can be used by modules, and is used
index b7254fd0b0d3bd3ba3b4a6fed6fe69fd2986257c..0951a3224b57cc3dd608b923ea4c8b7d65b46e7a 100644 (file)
@@ -84,13 +84,18 @@ bool CullList::IsValid(userrec* user)
 CullItem::CullItem(userrec* u, std::string &r)
 {
         this->user = u;
-        this->reason = r;
+        this->reason = strdup(r.c_str());
 }
 
 CullItem::CullItem(userrec* u, const char* r)
 {
        this->user = u;
-       this->reason = r;
+       this->reason = strdup(r);
+}
+
+CullItem::~CullItem()
+{
+       free(reason);
 }
 
 userrec* CullItem::GetUser()
@@ -98,7 +103,7 @@ userrec* CullItem::GetUser()
         return this->user;
 }
 
-std::string CullItem::GetReason()
+const char* CullItem::GetReason()
 {
         return this->reason;
 }
@@ -145,7 +150,7 @@ int CullList::Apply()
                 */
                if (IsValid(u))
                {
-                       kill_link(u,a->GetReason().c_str());
+                       kill_link(u,a->GetReason());
                        list.erase(list.begin());
                        /* So that huge numbers of quits dont block,
                         * we yield back to our mainloop every 15
index c9ebce74d700c52589c0f1916f0b39a14020def1..8b1f627c162ae0f829ffdac90be12077c32f2ab7 100755 (executable)
@@ -1 +1 @@
-echo 3623
+echo 3625