diff options
author | Peter Powell <petpow@saberuk.com> | 2013-05-18 18:40:55 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2013-06-06 01:45:04 +0100 |
commit | c5bc6c1cf52464308797c1fd648062363504b48b (patch) | |
tree | 8e4e3f341b07af5d60cee9d2779ae9f5a2bb7e17 | |
parent | 6f54bc95a483dfb7b6aaf0af02a1243d74e89f4c (diff) |
Replace some C string operations with the + operator.
-rw-r--r-- | include/users.h | 6 | ||||
-rw-r--r-- | src/modules/m_messageflood.cpp | 2 | ||||
-rw-r--r-- | src/users.cpp | 72 |
3 files changed, 9 insertions, 71 deletions
diff --git a/include/users.h b/include/users.h index 52f3e4a88..e27a764dc 100644 --- a/include/users.h +++ b/include/users.h @@ -481,12 +481,6 @@ class CoreExport User : public Extensible */ virtual bool HasModePermission(unsigned char mode, ModeType type); - /** Creates a wildcard host. - * Takes a buffer to use and fills the given buffer with the host in the format *!*\@hostname - * @return The wildcarded hostname in *!*\@host form - */ - char* MakeWildHost(); - /** Creates a usermask with real host. * Takes a buffer to use and fills the given buffer with the hostmask in the format user\@host * @return the usermask in the format user\@host diff --git a/src/modules/m_messageflood.cpp b/src/modules/m_messageflood.cpp index 970087bef..65c3354a9 100644 --- a/src/modules/m_messageflood.cpp +++ b/src/modules/m_messageflood.cpp @@ -155,7 +155,7 @@ class ModuleMsgFlood : public Module std::vector<std::string> parameters; parameters.push_back(dest->name); parameters.push_back("+b"); - parameters.push_back(user->MakeWildHost()); + parameters.push_back("*!*@" + user->dhost); ServerInstance->SendGlobalMode(parameters, ServerInstance->FakeClient); } diff --git a/src/users.cpp b/src/users.cpp index a12b322b7..a8359692a 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -220,18 +220,8 @@ const std::string& User::MakeHost() if (!this->cached_makehost.empty()) return this->cached_makehost; - char nhost[MAXBUF]; - /* This is much faster than snprintf */ - char* t = nhost; - for(const char* n = ident.c_str(); *n; n++) - *t++ = *n; - *t++ = '@'; - for(const char* n = host.c_str(); *n; n++) - *t++ = *n; - *t = 0; - - this->cached_makehost.assign(nhost); - + // XXX: Is there really a need to cache this? + this->cached_makehost = ident + "@" + host; return this->cached_makehost; } @@ -240,18 +230,8 @@ const std::string& User::MakeHostIP() if (!this->cached_hostip.empty()) return this->cached_hostip; - char ihost[MAXBUF]; - /* This is much faster than snprintf */ - char* t = ihost; - for(const char* n = ident.c_str(); *n; n++) - *t++ = *n; - *t++ = '@'; - for(const char* n = this->GetIPString().c_str(); *n; n++) - *t++ = *n; - *t = 0; - - this->cached_hostip = ihost; - + // XXX: Is there really a need to cache this? + this->cached_hostip = ident + "@" + this->GetIPString(); return this->cached_hostip; } @@ -260,54 +240,18 @@ const std::string& User::GetFullHost() if (!this->cached_fullhost.empty()) return this->cached_fullhost; - char result[MAXBUF]; - char* t = result; - for(const char* n = nick.c_str(); *n; n++) - *t++ = *n; - *t++ = '!'; - for(const char* n = ident.c_str(); *n; n++) - *t++ = *n; - *t++ = '@'; - for(const char* n = dhost.c_str(); *n; n++) - *t++ = *n; - *t = 0; - - this->cached_fullhost = result; - + // XXX: Is there really a need to cache this? + this->cached_fullhost = nick + "!" + ident + "@" + dhost; return this->cached_fullhost; } -char* User::MakeWildHost() -{ - static char nresult[MAXBUF]; - char* t = nresult; - *t++ = '*'; *t++ = '!'; - *t++ = '*'; *t++ = '@'; - for(const char* n = dhost.c_str(); *n; n++) - *t++ = *n; - *t = 0; - return nresult; -} - const std::string& User::GetFullRealHost() { if (!this->cached_fullrealhost.empty()) return this->cached_fullrealhost; - char fresult[MAXBUF]; - char* t = fresult; - for(const char* n = nick.c_str(); *n; n++) - *t++ = *n; - *t++ = '!'; - for(const char* n = ident.c_str(); *n; n++) - *t++ = *n; - *t++ = '@'; - for(const char* n = host.c_str(); *n; n++) - *t++ = *n; - *t = 0; - - this->cached_fullrealhost = fresult; - + // XXX: Is there really a need to cache this? + this->cached_fullrealhost = nick + "!" + ident + "@" + host; return this->cached_fullrealhost; } |