You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2011/12/08 14:44:38 UTC

svn commit: r1211883 - /activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala

Author: chirino
Date: Thu Dec  8 13:44:37 2011
New Revision: 1211883

URL: http://svn.apache.org/viewvc?rev=1211883&view=rev
Log:
Avoid creating a TreeSet if it's not needed or if the values are not sortable.

Modified:
    activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala

Modified: activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala?rev=1211883&r1=1211882&r2=1211883&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala (original)
+++ activemq/activemq-apollo/trunk/apollo-util/src/main/scala/org/apache/activemq/apollo/util/path/PathMap.scala Thu Dec  8 13:44:37 2011
@@ -91,6 +91,10 @@ class PathMap[Value] {
     if ((set == null) || set.isEmpty) {
       return null.asInstanceOf[Value]
     }
+    var first: Value = set.iterator().next()
+    if( set.size()==1 || !first.isInstanceOf[java.lang.Comparable[_]]) {
+      return first;
+    }
     var sortedSet: SortedSet[Value] = new TreeSet[Value](set)
     return sortedSet.last
   }