From 57f498f8045c9ca010b09b860fe7c5a9ef9cf8c4 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 10 Mar 2006 12:13:19 +0000 Subject: Faster CullItem/CullList using strdup rather than copying a std::string git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3626 e03df62e-2008-0410-955e-edbf42e46eb7 --- include/cull_list.h | 7 +++++-- src/cull_list.cpp | 13 +++++++++---- src/svn-rev.sh | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/include/cull_list.h b/include/cull_list.h index ca7189f4c..df91e2eca 100644 --- a/include/cull_list.h +++ b/include/cull_list.h @@ -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 diff --git a/src/cull_list.cpp b/src/cull_list.cpp index b7254fd0b..0951a3224 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -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 diff --git a/src/svn-rev.sh b/src/svn-rev.sh index c9ebce74d..8b1f627c1 100755 --- a/src/svn-rev.sh +++ b/src/svn-rev.sh @@ -1 +1 @@ -echo 3623 +echo 3625 -- cgit v1.2.3