harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r544792 - /harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
Date Wed, 06 Jun 2007 10:04:25 GMT
Author: tellison
Date: Wed Jun  6 03:04:23 2007
New Revision: 544792

URL: http://svn.apache.org/viewvc?view=rev&rev=544792
Log:
Apply patch HARMONY-4061 ([classlib][luni] Performance improvement of java.util.Collections)

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java?view=diff&rev=544792&r1=544791&r2=544792
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/Collections.java
Wed Jun  6 03:04:23 2007
@@ -575,15 +575,51 @@
         }
 
         public int indexOf(Object object) {
+            final int size;
+            final Object[] array;
             synchronized (mutex) {
-                return list.indexOf(object);
+                size = list.size();
+                array = new Object[size];
+                list.toArray(array);
             }
+            if (null != object)
+                for (int i = 0; i < size; i++) {
+                    if (object.equals(array[i])) {
+                        return i;
+                    }
+                }
+            else {
+                for (int i = 0; i < size; i++) {
+                    if (null == array[i]) {
+                        return i;
+                    }
+                }
+            }
+            return -1;
         }
 
         public int lastIndexOf(Object object) {
+            final int size;
+            final Object[] array;
             synchronized (mutex) {
-                return list.lastIndexOf(object);
+                size = list.size();
+                array = new Object[size];
+                list.toArray(array);
+            }
+            if (null != object)
+                for (int i = size - 1; i >= 0; i--) {
+                    if (object.equals(array[i])) {
+                        return i;
+                    }
+                }
+            else {
+                for (int i = size - 1; i >= 0; i--) {
+                    if (null == array[i]) {
+                        return i;
+                    }
+                }
             }
+            return -1;
         }
 
         public ListIterator<E> listIterator() {



Mime
View raw message