diff options
author | Peter Powell <petpow@saberuk.com> | 2017-12-23 15:56:23 +0000 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2017-12-23 15:56:23 +0000 |
commit | e73b78ca679281608eedcda0f697fc4b1cd030b3 (patch) | |
tree | fd5e845891ff01fc9da2ebfd5501d4fb37e3c779 | |
parent | 198e2a442c9c3fffb5ecc9ff18a6e99cf4c7d912 (diff) |
Use a bitset in blockcaps instead of a char array.
-rw-r--r-- | src/modules/m_blockcaps.cpp | 9 |
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 |