summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2017-12-23 15:56:23 +0000
committerPeter Powell <petpow@saberuk.com>2017-12-23 15:56:23 +0000
commite73b78ca679281608eedcda0f697fc4b1cd030b3 (patch)
treefd5e845891ff01fc9da2ebfd5501d4fb37e3c779 /src/modules
parent198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912 (diff)
Use a bitset in blockcaps instead of a char array.
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/m_blockcaps.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/modules/m_blockcaps.cpp b/src/modules/m_blockcaps.cpp
index d7cd303b6..b5347e9ad 100644
--- a/src/modules/m_blockcaps.cpp
+++ b/src/modules/m_blockcaps.cpp
@@ -29,7 +29,7 @@ class ModuleBlockCAPS : public Module
SimpleChannelModeHandler bc;
unsigned int percent;
unsigned int minlen;
- char capsmap[256];
+ std::bitset<UCHAR_MAX> capsmap;
public:
ModuleBlockCAPS()
@@ -65,7 +65,8 @@ public:
offset = 8;
for (std::string::const_iterator i = text.begin() + offset; i != text.end(); ++i)
- caps += capsmap[(unsigned char)*i];
+ if (capsmap.test(*i))
+ caps += 1;
if (((caps * 100) / text.length()) >= percent)
{
@@ -83,9 +84,9 @@ public:
percent = tag->getInt("percent", 100, 1, 100);
minlen = tag->getInt("minlen", 1, 1, ServerInstance->Config->Limits.MaxLine);
std::string hmap = tag->getString("capsmap", "ABCDEFGHIJKLMNOPQRSTUVWXYZ");
- memset(capsmap, 0, sizeof(capsmap));
+ capsmap.reset();
for (std::string::iterator n = hmap.begin(); n != hmap.end(); n++)
- capsmap[(unsigned char)*n] = 1;
+ capsmap.set(*n);
}
Version GetVersion() CXX11_OVERRIDE