From fd655fa93a00a5f2993adb7ef562b6dbab8aa87c Mon Sep 17 00:00:00 2001 From: Peter Powell Date: Mon, 1 Apr 2013 05:25:03 +0100 Subject: Purge the deprecated hash_map from existance. --- include/bancache.h | 2 +- include/dns.h | 2 +- include/hash_map.h | 59 --------------------------------------- include/hashcomp.h | 81 +++++++++++------------------------------------------- include/inspircd.h | 6 ++++ include/typedefs.h | 11 ++------ 6 files changed, 27 insertions(+), 134 deletions(-) delete mode 100644 include/hash_map.h (limited to 'include') diff --git a/include/bancache.h b/include/bancache.h index a7aac7f17..a99e97856 100644 --- a/include/bancache.h +++ b/include/bancache.h @@ -65,7 +65,7 @@ class CoreExport BanCacheHit /* A container of ban cache items. * must be defined after class BanCacheHit. */ -typedef nspace::hash_map > BanCacheHash; +typedef std::tr1::unordered_map > BanCacheHash; /** A manager for ban cache, which allocates and deallocates and checks cached bans. */ diff --git a/include/dns.h b/include/dns.h index 27c3c8848..3c8e55d08 100644 --- a/include/dns.h +++ b/include/dns.h @@ -102,7 +102,7 @@ class CoreExport CachedQuery /** DNS cache information. Holds IPs mapped to hostnames, and hostnames mapped to IPs. */ -typedef nspace::hash_map dnscache; +typedef std::tr1::unordered_map dnscache; /** * Error types that class Resolver can emit to its error method. diff --git a/include/hash_map.h b/include/hash_map.h deleted file mode 100644 index 1b43f0118..000000000 --- a/include/hash_map.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * Copyright (C) 2009 Robin Burchell - * Copyright (C) 2008 Craig Edwards - * Copyright (C) 2007 Dennis Friis - * Copyright (C) 2006 Oliver Lupton - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - - -#ifndef INSPIRCD_HASHMAP_H -#define INSPIRCD_HASHMAP_H - - /** Where hash_map is varies from compiler to compiler - * as it is not standard unless we have tr1. - * - * TODO: in 2.2 if we drop support for libstdc++ older than 3.4.7 and GCC older - * than 4.1 this can be cleaned up massively. - */ - #ifndef _WIN32 - #if __GLIBCXX__ > 20060309 - // GCC4+ has deprecated hash_map and uses tr1. But of course, uses a different include to MSVC. FOR FUCKS SAKE. - #include - #define HAS_TR1_UNORDERED - #define HASHMAP_DEPRECATED - #else - #include - /** Oddball linux namespace for hash_map */ - #define nspace __gnu_cxx - #define BEGIN_HASHMAP_NAMESPACE namespace nspace { - #define END_HASHMAP_NAMESPACE } - #endif - #else - #include - #define HAS_TR1_UNORDERED - #define HASHMAP_DEPRECATED - #endif - - // tr1: restoring sanity to our headers. now if only compiler vendors could agree on a FUCKING INCLUDE FILE. - #ifdef HAS_TR1_UNORDERED - #define hash_map unordered_map - #define nspace std::tr1 - #define BEGIN_HASHMAP_NAMESPACE namespace std { namespace tr1 { - #define END_HASHMAP_NAMESPACE } } - #endif - -#endif diff --git a/include/hashcomp.h b/include/hashcomp.h index 78d7ee878..449b367b9 100644 --- a/include/hashcomp.h +++ b/include/hashcomp.h @@ -31,7 +31,7 @@ #include #include #include -#include "hash_map.h" +#include "inspircd.h" /******************************************************* * This file contains classes and templates that deal @@ -591,71 +591,22 @@ inline std::string& trim(std::string &str) return str; } -/** Hashing stuff is totally different on vc++'s hash_map implementation, so to save a buttload of - * \#ifdefs we'll just do it all at once. Except, of course, with TR1, when it's the same as GCC. - */ -BEGIN_HASHMAP_NAMESPACE - - /** Hashing function to hash irc::string - */ -#if defined(_WIN32) && !defined(HAS_TR1_UNORDERED) - template<> class CoreExport hash_compare > - { - public: - enum { bucket_size = 4, min_buckets = 8 }; /* Got these numbers from the CRT source, if anyone wants to change them feel free. */ - - /** Compare two irc::string values for hashing in hash_map - */ - bool operator()(const irc::string & s1, const irc::string & s2) const - { - if(s1.length() != s2.length()) return true; - return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), (size_t)s1.length()) < 0); - } - - /** Hash an irc::string value for hash_map - */ - size_t operator()(const irc::string & s) const; - }; - - template<> class CoreExport hash_compare > +namespace std +{ + namespace tr1 { - public: - enum { bucket_size = 4, min_buckets = 8 }; /* Again, from the CRT source */ - - /** Compare two std::string values for hashing in hash_map - */ - bool operator()(const std::string & s1, const std::string & s2) const + + struct insensitive { - if(s1.length() != s2.length()) return true; - return (irc::irc_char_traits::compare(s1.c_str(), s2.c_str(), (size_t)s1.length()) < 0); - } - - /** Hash a std::string using RFC1459 case sensitivity rules - * @param s A string to hash - * @return The hash value - */ - size_t operator()(const std::string & s) const; - }; -#else - - /* XXX FIXME: Implement a hash function overriding std::string's that works with TR1! */ - -#ifdef HASHMAP_DEPRECATED - struct insensitive -#else - CoreExport template<> struct hash -#endif - { - size_t CoreExport operator()(const std::string &s) const; - }; - -#endif - - /** Convert a string to lower case respecting RFC1459 - * @param n A string to lowercase - */ - void strlower(char *n); - -END_HASHMAP_NAMESPACE + size_t CoreExport operator()(const std::string &s) const; + }; + + /** Convert a string to lower case respecting RFC1459 + * @param n A string to lowercase + */ + void strlower(char *n); + + } +} #endif diff --git a/include/inspircd.h b/include/inspircd.h index 86853a94f..9456ce329 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -58,6 +58,11 @@ #include #endif +#ifdef _WIN32 +# include +#else +# include +#endif #include #include #include @@ -896,3 +901,4 @@ class CommandModule : public Module }; #endif + diff --git a/include/typedefs.h b/include/typedefs.h index 06f704120..e73790667 100644 --- a/include/typedefs.h +++ b/include/typedefs.h @@ -56,13 +56,8 @@ struct ResourceRecord; #include "hashcomp.h" #include "base.h" -#ifdef HASHMAP_DEPRECATED - typedef nspace::hash_map user_hash; - typedef nspace::hash_map chan_hash; -#else - typedef nspace::hash_map, irc::StrHashComp> user_hash; - typedef nspace::hash_map, irc::StrHashComp> chan_hash; -#endif +typedef std::tr1::unordered_map user_hash; +typedef std::tr1::unordered_map chan_hash; /** A list holding local users, this is the type of UserManager::local_users */ @@ -120,7 +115,7 @@ typedef std::map ConfigFileCache; /** A hash of commands used by the core */ -typedef nspace::hash_map Commandtable; +typedef std::tr1::unordered_map Commandtable; /** Membership list of a channel */ typedef std::map UserMembList; -- cgit v1.2.3