classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [really patch] Re: HashMap putAll/putAllInternal bug


From: Ingo Prötel
Subject: Re: [really patch] Re: HashMap putAll/putAllInternal bug
Date: Fri, 07 Nov 2003 11:06:56 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624

Hi Stuart,

I have commited your patch:

2003-11-07  Stuart Ballard <address@hidden>

        * java/util/HashMap.java (putAll): Use Iterator hasNext() method.
        (putAllInternal): Likewise.
        * java/util/Hashtable.java (putAll): Use Iterator hasNext() method.
        (putAllInternal): Likewise.

Ingo



Stuart Ballard wrote:
Stuart Ballard wrote:

Nobody spoke up, so could someone apply the patch (attached)?


Anybody? :)

Stuart.


------------------------------------------------------------------------

Index: HashMap.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/HashMap.java,v
retrieving revision 1.24
diff -u -r1.24 HashMap.java
--- HashMap.java        1 Aug 2003 03:31:32 -0000       1.24
+++ HashMap.java        25 Sep 2003 18:16:52 -0000
@@ -381,8 +381,7 @@
   public void putAll(Map m)
   {
     Iterator itr = m.entrySet().iterator();
-    int msize = m.size();
-    while (msize-- > 0)
+    while (itr.hasNext())
       {
         Map.Entry e = (Map.Entry) itr.next();
         // Optimize in case the Entry is one of our own.
@@ -709,10 +708,10 @@
   void putAllInternal(Map m)
   {
     Iterator itr = m.entrySet().iterator();
-    int msize = m.size();
-    size = msize;
-    while (msize-- > 0)
+    size = 0;
+    while (itr.hasNext())
       {
+        size++;
        Map.Entry e = (Map.Entry) itr.next();
        Object key = e.getKey();
        int idx = hash(key);
Index: Hashtable.java
===================================================================
RCS file: /cvsroot/classpath/classpath/java/util/Hashtable.java,v
retrieving revision 1.28
diff -u -r1.28 Hashtable.java
--- Hashtable.java      7 May 2002 05:13:05 -0000       1.28
+++ Hashtable.java      25 Sep 2003 18:16:52 -0000
@@ -510,7 +510,7 @@
   {
     Iterator itr = m.entrySet().iterator();
- for (int msize = m.size(); msize > 0; msize--)
+    while (itr.hasNext())
       {
         Map.Entry e = (Map.Entry) itr.next();
         // Optimize in case the Entry is one of our own.
@@ -859,11 +859,11 @@
   void putAllInternal(Map m)
   {
     Iterator itr = m.entrySet().iterator();
-    int msize = m.size();
-    this.size = msize;
+    size = 0;
- for (; msize > 0; msize--)
+    while (itr.hasNext())
       {
+        size++;
        Map.Entry e = (Map.Entry) itr.next();
        Object key = e.getKey();
        int idx = hash(key);


------------------------------------------------------------------------

_______________________________________________
Classpath mailing list
address@hidden
http://mail.gnu.org/mailman/listinfo/classpath





reply via email to

[Prev in Thread] Current Thread [Next in Thread]