commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1443538 - /commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java
Date Thu, 07 Feb 2013 15:12:21 GMT
Author: tn
Date: Thu Feb  7 15:12:21 2013
New Revision: 1443538

URL: http://svn.apache.org/viewvc?rev=1443538&view=rev
Log:
[COLLECTIONS-312] use known collection size when creating arrays / lists.

Modified:
    commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java

Modified: commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java?rev=1443538&r1=1443537&r2=1443538&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java
(original)
+++ commons/proper/collections/trunk/src/main/java/org/apache/commons/collections/map/AbstractReferenceMap.java
Thu Feb  7 15:12:21 2013
@@ -514,13 +514,13 @@ public abstract class AbstractReferenceM
 
         @Override
         public Object[] toArray() {
-            return toArray(new Object[0]);
+            return toArray(new Object[size()]);
         }
 
         @Override
         public <T> T[] toArray(final T[] arr) {
             // special implementation to handle disappearing entries
-            final ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K,
V>>();
+            final ArrayList<Map.Entry<K, V>> list = new ArrayList<Map.Entry<K,
V>>(size());
             for (final Map.Entry<K, V> entry : this) {
                 list.add(new DefaultMapEntry<K, V>(entry));
             }
@@ -540,13 +540,13 @@ public abstract class AbstractReferenceM
 
         @Override
         public Object[] toArray() {
-            return toArray(new Object[0]);
+            return toArray(new Object[size()]);
         }
 
         @Override
         public <T> T[] toArray(final T[] arr) {
             // special implementation to handle disappearing keys
-            final List<K> list = new ArrayList<K>(parent.size());
+            final List<K> list = new ArrayList<K>(size());
             for (final K key : this) {
                 list.add(key);
             }
@@ -566,13 +566,13 @@ public abstract class AbstractReferenceM
 
         @Override
         public Object[] toArray() {
-            return toArray(new Object[0]);
+            return toArray(new Object[size()]);
         }
 
         @Override
         public <T> T[] toArray(final T[] arr) {
             // special implementation to handle disappearing values
-            final List<V> list = new ArrayList<V>(parent.size());
+            final List<V> list = new ArrayList<V>(size());
             for (final V value : this) {
                 list.add(value);
             }



Mime
View raw message