Slightly better Utils::push_sorted
authorclinton <clinton@unknownlamer.org>
Tue, 18 Nov 2008 21:41:48 +0000 (21:41 +0000)
committerclinton <clinton@unknownlamer.org>
Tue, 18 Nov 2008 21:41:48 +0000 (21:41 +0000)
No need to special case the not found case

source/Utils.H

index 0c5c008..46c0496 100644 (file)
@@ -87,13 +87,10 @@ namespace Utils {
   template<typename T, typename C> 
   void push_sorted (std::list<T> & storage, T item, C compare)
   {
-    typename std::list<T>::iterator it = 
-      std::find_if (storage.begin (), storage.end (), 
-                   std::bind1st (compare, item));
-    if (it != storage.end ())
-      storage.insert (it, item);
-    else
-      storage.push_back (item);
+    storage.insert (std::find_if (storage.begin (), storage.end (), 
+                                 std::bind1st (compare, item)),
+                   item);
+
   }
 }