summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2020-01-07 23:45:10 +0000
committerSadie Powell <sadie@witchery.services>2020-01-07 23:45:10 +0000
commit0ff2d05ba6b94c5346e6e3e528118fadae1cb126 (patch)
tree903accba55e6d619ebb7cba79af88bf7dad3f931 /src
parent3dd446de4155227d423e83628a10195e46b385aa (diff)
Minor improvements to the codepage module.
- Cache the codepage name on load and restore on unload. - Make origisnick constant. - Fix the size of the casemap in memcmp call.
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_codepage.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/modules/m_codepage.cpp b/src/modules/m_codepage.cpp
index 1c3ac02da..911a4781e 100644
--- a/src/modules/m_codepage.cpp
+++ b/src/modules/m_codepage.cpp
@@ -62,8 +62,11 @@ class ModuleCodepage
// The character map which was set before this module was loaded.
const unsigned char* origcasemap;
+ // The name of the character map which was set before this module was loaded.
+ const std::string origcasemapname;
+
// The IsNick handler which was set before this module was loaded.
- TR1NS::function<bool(const std::string&)> origisnick;
+ const TR1NS::function<bool(const std::string&)> origisnick;
template <typename T>
void RehashHashmap(T& hashmap)
@@ -87,7 +90,7 @@ class ModuleCodepage
void CheckRehash(unsigned char* prevmap)
{
- if (!memcmp(prevmap, national_case_insensitive_map, sizeof(origcasemap)))
+ if (!memcmp(prevmap, national_case_insensitive_map, UCHAR_MAX))
return;
RehashHashmap(ServerInstance->Users.clientlist);
@@ -98,6 +101,7 @@ class ModuleCodepage
public:
ModuleCodepage()
: origcasemap(national_case_insensitive_map)
+ , origcasemapname(ServerInstance->Config->CaseMapping)
, origisnick(ServerInstance->IsNick)
{
}
@@ -107,6 +111,7 @@ class ModuleCodepage
ServerInstance->IsNick = origisnick;
CheckInvalidNick();
+ ServerInstance->Config->CaseMapping = origcasemapname;
national_case_insensitive_map = origcasemap;
CheckRehash(casemap);
}