From 709c1eeae90dae106800e3742f3655bd7b590b7b Mon Sep 17 00:00:00 2001
From: Nat Goodspeed <nat@lindenlab.com>
Date: Wed, 11 Jul 2012 14:13:45 -0400
Subject: MAINT-1175: Properly pass LLRegistry's COMPARATOR to underlying map.
 Although LLRegistry and LLRegistrySingleton have always defined a COMPARATOR
 template parameter, it wasn't used for the underlying map. Therefore every
 type, including any pointer type, was being compared using std::less. This
 happens to work most of the time -- but is tripping us up now. Pass
 COMPARATOR to underlying std::map. Fix a couple minor bugs in
 LLRegistryDefaultComparator (never before used!). Specialize for const char*.
 Remove CompareTypeID and LLCompareTypeID because we now actively forbid using
 LLRegistry<std::type_info*, ...>; remove only known reference
 (LLWidgetNameRegistry definition).

---
 indra/llcommon/llinitparam.h |  8 --------
 indra/llcommon/llregistry.h  | 16 +++++++++++++---
 2 files changed, 13 insertions(+), 11 deletions(-)

(limited to 'indra/llcommon')

diff --git a/indra/llcommon/llinitparam.h b/indra/llcommon/llinitparam.h
index c0170e533b..66c72c2d9f 100644
--- a/indra/llcommon/llinitparam.h
+++ b/indra/llcommon/llinitparam.h
@@ -212,14 +212,6 @@ namespace LLInitParam
 
 	public:
 		
-		struct CompareTypeID
-		{
-			bool operator()(const std::type_info* lhs, const std::type_info* rhs) const
-			{
-				return lhs->before(*rhs);
-			}
-		};
-
 		typedef std::vector<std::pair<std::string, bool> >					name_stack_t;
 		typedef std::pair<name_stack_t::iterator, name_stack_t::iterator>	name_stack_range_t;
 		typedef std::vector<std::string>									possible_values_t;
diff --git a/indra/llcommon/llregistry.h b/indra/llcommon/llregistry.h
index 843c169f3d..8eeab59024 100644
--- a/indra/llcommon/llregistry.h
+++ b/indra/llcommon/llregistry.h
@@ -34,9 +34,19 @@
 #include "llsingleton.h"
 
 template <typename T>
-class LLRegistryDefaultComparator
+struct LLRegistryDefaultComparator
 {
-	bool operator()(const T& lhs, const T& rhs) { return lhs < rhs; }
+	bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; }
+};
+
+// comparator for const char* registry keys
+template <>
+struct LLRegistryDefaultComparator<const char*>
+{
+	bool operator()(const char* lhs, const char* rhs) const
+	{
+		return strcmp(lhs, rhs) < 0;
+	}
 };
 
 template <typename KEY, typename VALUE, typename COMPARATOR = LLRegistryDefaultComparator<KEY> >
@@ -62,7 +72,7 @@ public:
 	{
 		friend class LLRegistry<KEY, VALUE, COMPARATOR>;
 	public:
-		typedef std::map<KEY, VALUE> registry_map_t;
+		typedef std::map<KEY, VALUE, COMPARATOR> registry_map_t;
 
 		bool add(ref_const_key_t key, ref_const_value_t value)
 		{
-- 
cgit v1.2.3