summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-07-19 20:34:14 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-07-19 20:34:14 +0000
commita67b9de1742efbff29ec08093b220565eab7df23 (patch)
tree1f0778b8e417fd24873b945f8d2e89a292a25942 /include
parente93827e41cdb958314eb669e94c9dd1280b691c9 (diff)
Change modes in channels and users to use std::bitset instead of an array. This saves 56 bytes per channel, and 112 bytes per channel, with no loss in speed or ease of use in code. :). Thanks (VERY) much to Special for telling me about this.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10043 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include')
-rw-r--r--include/channels.h4
-rw-r--r--include/configreader.h1
-rw-r--r--include/globals.h37
-rw-r--r--include/inspircd.h28
-rw-r--r--include/modules.h1
-rw-r--r--include/socketengines/socketengine_epoll.h1
-rw-r--r--include/socketengines/socketengine_iocp.h1
-rw-r--r--include/socketengines/socketengine_kqueue.h1
-rw-r--r--include/socketengines/socketengine_ports.h1
-rw-r--r--include/socketengines/socketengine_select.h1
-rw-r--r--include/users.h12
11 files changed, 33 insertions, 55 deletions
diff --git a/include/channels.h b/include/channels.h
index 0d4c4813c..2042df220 100644
--- a/include/channels.h
+++ b/include/channels.h
@@ -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
diff --git a/include/configreader.h b/include/configreader.h
index 7a753bcc7..51eb2f5fd 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -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
index 2de2ba11b..000000000
--- a/include/globals.h
+++ /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
diff --git a/include/inspircd.h b/include/inspircd.h
index 9ef5dbcfb..a225c7e3a 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -38,6 +38,31 @@
#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*);
diff --git a/include/modules.h b/include/modules.h
index 7945a33ad..772f4ab5f 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -14,7 +14,6 @@
#ifndef __MODULES_H
#define __MODULES_H
-#include "globals.h"
#include "dynamic.h"
#include "base.h"
#include "ctables.h"
diff --git a/include/socketengines/socketengine_epoll.h b/include/socketengines/socketengine_epoll.h
index 07d0e3621..517f93d2e 100644
--- a/include/socketengines/socketengine_epoll.h
+++ b/include/socketengines/socketengine_epoll.h
@@ -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>
diff --git a/include/socketengines/socketengine_iocp.h b/include/socketengines/socketengine_iocp.h
index 845228967..80689017c 100644
--- a/include/socketengines/socketengine_iocp.h
+++ b/include/socketengines/socketengine_iocp.h
@@ -19,7 +19,6 @@
#include "inspircd_config.h"
#include "inspircd_win32wrapper.h"
-#include "globals.h"
#include "inspircd.h"
#include "socketengine.h"
diff --git a/include/socketengines/socketengine_kqueue.h b/include/socketengines/socketengine_kqueue.h
index 49b51590a..14664918a 100644
--- a/include/socketengines/socketengine_kqueue.h
+++ b/include/socketengines/socketengine_kqueue.h
@@ -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>
diff --git a/include/socketengines/socketengine_ports.h b/include/socketengines/socketengine_ports.h
index 519eaad8b..0b0655fb0 100644
--- a/include/socketengines/socketengine_ports.h
+++ b/include/socketengines/socketengine_ports.h
@@ -22,7 +22,6 @@
#include <string>
#include <map>
#include "inspircd_config.h"
-#include "globals.h"
#include "inspircd.h"
#include "socketengine.h"
#include <port.h>
diff --git a/include/socketengines/socketengine_select.h b/include/socketengines/socketengine_select.h
index cb4ed0ecf..91746b252 100644
--- a/include/socketengines/socketengine_select.h
+++ b/include/socketengines/socketengine_select.h
@@ -21,7 +21,6 @@
#include <sys/select.h>
#endif // WINDOWS
#include "inspircd_config.h"
-#include "globals.h"
#include "inspircd.h"
#include "socketengine.h"
diff --git a/include/users.h b/include/users.h
index 39abc6309..503a1e568 100644
--- a/include/users.h
+++ b/include/users.h
@@ -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
*/