]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Change modes in channels and users to use std::bitset instead of an array. This saves...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 19 Jul 2008 20:34:14 +0000 (20:34 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sat, 19 Jul 2008 20:34:14 +0000 (20:34 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10043 e03df62e-2008-0410-955e-edbf42e46eb7

14 files changed:
configure
include/channels.h
include/configreader.h
include/globals.h [deleted file]
include/inspircd.h
include/modules.h
include/socketengines/socketengine_epoll.h
include/socketengines/socketengine_iocp.h
include/socketengines/socketengine_kqueue.h
include/socketengines/socketengine_ports.h
include/socketengines/socketengine_select.h
include/users.h
src/modes/umode_n.cpp
src/users.cpp

index 272698f962d0fc012fe93bd8a1d4f62013eea10d..e03739820363e1bae9f48d396d788b8af71773cc 100755 (executable)
--- a/configure
+++ b/configure
@@ -1728,7 +1728,7 @@ ITEM
        # now print the command file details.
        foreach my $cmd (@cmdlist) {
                print FH <<ITEM;
-cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/globals.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h
+cmd_$cmd.so: cmd_$cmd.cpp ../../include/base.h ../../include/modules.h ../../include/inspircd.h ../../include/channels.h ../../include/users.h ../../include/inspircd_config.h ../../include/commands/cmd_$cmd.h
        \@../../make/run-cc.pl \$(CC) -pipe -I../../include \$(FLAGS) -export-dynamic $SHARED -o cmd_$cmd.so cmd_$cmd.cpp
 
 ITEM
index 0d4c4813c28e114d17275f6e1a4a7d5cf843e39f..2042df2209d31f51f72b9b839c02b5d5b6c84639 100644 (file)
@@ -137,12 +137,12 @@ class CoreExport Channel : public Extensible
        std::string name; /* CHANMAX */
 
        /** Modes for the channel.
-        * This is not a null terminated string! It is a hash where
+        * This is not a null terminated string! It is a bitset where
         * each item in it represents if a mode is set. For example
         * for mode +A, index 0. Use modechar-65 to calculate which
         * field to check.
         */
-       unsigned char modes[64];
+       std::bitset<64> modes;
 
        /** User lists.
         * There are four user lists, one for 
index 7a753bcc705a5d37070959391605bac9b4fa0350..51eb2f5fd9098b8661cfd25c2b5c09f635b2e163 100644 (file)
@@ -26,7 +26,6 @@
 #include <vector>
 #include <map>
 #include "inspircd.h"
-#include "globals.h"
 #include "modules.h"
 #include "socketengine.h"
 #include "socket.h"
diff --git a/include/globals.h b/include/globals.h
deleted file mode 100644 (file)
index 2de2ba1..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-/*       +------------------------------------+
- *       | Inspire Internet Relay Chat Daemon |
- *       +------------------------------------+
- *
- *  InspIRCd: (C) 2002-2008 InspIRCd Development Team
- * See: http://www.inspircd.org/wiki/index.php/Credits
- *
- * This program is free but copyrighted software; see
- *            the file COPYING for details.
- *
- * ---------------------------------------------------
- */
-
-#ifndef __WORLD_H
-#define __WORLD_H
-
-#include <vector>
-#include <deque>
-#include <map>
-
-/** A cached text file stored with its contents as lines
- */
-typedef std::deque< std::string > file_cache;
-
-/** A configuration key and value pair
- */
-typedef std::pair< std::string, std::string > KeyVal;
-
-/** A list of related configuration keys and values
- */
-typedef std::vector< KeyVal > KeyValList;
-
-/** An entire config file, built up of KeyValLists
- */
-typedef std::multimap< std::string, KeyValList > ConfigDataHash;
-
-#endif
index 9ef5dbcfb932f80587852d6481db4fa43b093c1a..a225c7e3a76aa77b749e77ee965c542af83f5f9a 100644 (file)
 #include <cmath>
 #include <cstring>
 #include <climits>
+#include <vector>
+#include <deque>
+#include <map>
+#include <bitset>
+
+
+/** A list of failed port bindings, used for informational purposes on startup */
+typedef std::vector<std::pair<std::string, std::string> > FailedPortList;
+
+/** A cached text file stored with its contents as lines
+ */
+typedef std::deque< std::string > file_cache;
+
+/** A configuration key and value pair
+ */
+typedef std::pair< std::string, std::string > KeyVal;
+
+/** A list of related configuration keys and values
+ */
+typedef std::vector< KeyVal > KeyValList;
+
+/** An entire config file, built up of KeyValLists
+ */
+typedef std::multimap< std::string, KeyValList > ConfigDataHash;
+
 
 #include "inspircd_config.h"
 #include "numerics.h"
@@ -234,9 +259,6 @@ class serverstats : public classbase
        }
 };
 
-/** A list of failed port bindings, used for informational purposes on startup */
-typedef std::vector<std::pair<std::string, std::string> > FailedPortList;
-
 class InspIRCd;
 
 DEFINE_HANDLER1(ProcessUserHandler, void, User*);
index 7945a33ad02eb9e357ebcb54cc736dde67c9dd93..772f4ab5f57310d9269ebc65e00c22db22c70f5d 100644 (file)
@@ -14,7 +14,6 @@
 #ifndef __MODULES_H
 #define __MODULES_H
 
-#include "globals.h"
 #include "dynamic.h"
 #include "base.h"
 #include "ctables.h"
index 07d0e3621801f296fc3a3b8765a5e9c30826f504..517f93d2e3142d6e15cdc4007403a451812467d7 100644 (file)
@@ -18,7 +18,6 @@
 #include <string>
 #include <map>
 #include "inspircd_config.h"
-#include "globals.h"
 #include "inspircd.h"
 #include "socketengine.h"
 #include <sys/epoll.h>
index 845228967bba913be96db4fe0dbf10b12c7ae2b3..80689017c2c9e9323eb62a2048b939389299b078 100644 (file)
@@ -19,7 +19,6 @@
 
 #include "inspircd_config.h"
 #include "inspircd_win32wrapper.h"
-#include "globals.h"
 #include "inspircd.h"
 #include "socketengine.h"
 
index 49b51590a2018f50ffa99c0218125044994a207c..14664918a4941ababe7be6ec7639ad0b6c78358e 100644 (file)
@@ -18,7 +18,6 @@
 #include <string>
 #include <map>
 #include "inspircd_config.h"
-#include "globals.h"
 #include "inspircd.h"
 #include <sys/types.h>
 #include <sys/event.h>
index 519eaad8b3e9f1879ebf28dbf4259f1fd086000f..0b0655fb0f98e92a94bd1cac554a430b2d23f267 100644 (file)
@@ -22,7 +22,6 @@
 #include <string>
 #include <map>
 #include "inspircd_config.h"
-#include "globals.h"
 #include "inspircd.h"
 #include "socketengine.h"
 #include <port.h>
index cb4ed0ecf6f88f544856a743a8f396d7a0691c49..91746b25228e8be6bc23fbaf8fa797a864798bfc 100644 (file)
@@ -21,7 +21,6 @@
 #include <sys/select.h>
 #endif // WINDOWS
 #include "inspircd_config.h"
-#include "globals.h"
 #include "inspircd.h"
 #include "socketengine.h"
 
index 39abc63095ad426e9735243ba766094d8a82f9fc..503a1e5680d146ad2965c9bf7b1a350711cd16a7 100644 (file)
@@ -17,7 +17,6 @@
 #include "socket.h"
 #include "connection.h"
 #include "dns.h"
-
 #include "mode.h"
 
 /** Channel status for a user
@@ -534,20 +533,21 @@ class CoreExport User : public connection
        std::string fullname;
        
        /** The user's mode list.
-        * This is NOT a null terminated string! In the 1.1 version of InspIRCd
-        * this is an array of values in a similar way to channel modes.
-        * A value of 1 in field (modeletter-65) indicates that the mode is
+        * NOT a null terminated string.
+        * Also NOT an array.
+        * Much love to the STL for giving us an easy to use bitset, saving us RAM.
+        * if (modes[modeletter-65]) is set, then the mode is
         * set, for example, to work out if mode +s is set, we  check the field
         * User::modes['s'-65] != 0.
         * The following RFC characters o, w, s, i have constants defined via an
         * enum, such as UM_SERVERNOTICE and UM_OPETATOR.
         */
-       unsigned char modes[64];
+       std::bitset<64> modes;
 
        /** What snomasks are set on this user.
         * This functions the same as the above modes.
         */
-       unsigned char snomasks[64];
+       std::bitset<64> snomasks;
 
        /** Channels this user is on, and the permissions they have there
         */
index ed08b60f4e80f73d6ec63ab6ba092c3d78afb889..ee3fe09b3018ccf20040fb112a6399d4e94c0108 100644 (file)
@@ -32,7 +32,7 @@ ModeAction ModeUserServerNoticeMask::OnModeChange(User* source, User* dest, Chan
        {
                /* Fix for bug #310 reported by Smartys */
                if (!dest->modes[UM_SNOMASK])
-                       memset(dest->snomasks, 0, sizeof(dest->snomasks));
+                       dest->snomasks.reset();
 
                parameter = dest->ProcessNoticeMasks(parameter.c_str());
                dest->modes[UM_SNOMASK] = true;
index a0ed42446e6f2087e654dc3e872f5d7b5a25be0f..3e9baba72d3e90812ff66c287627910670957138 100644 (file)
@@ -205,8 +205,6 @@ User::User(InspIRCd* Instance, const std::string &uid) : ServerInstance(Instance
        AllowedOperCommands = NULL;
        chans.clear();
        invites.clear();
-       memset(modes,0,sizeof(modes));
-       memset(snomasks,0,sizeof(snomasks));
 
        if (uid.empty())
                uuid.assign(Instance->GetUID(), 0, UUID_LENGTH - 1);