Commit 32ffbe92 by Stuart Ballard Committed by Michael Koch

HashMap.java (putAll): Use Iterator hasNext() method.

2003-11-26  Stuart Ballard <stuart.ballard@corp.fast.net>

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

From-SVN: r73964
parent cb5599c7
2003-11-26 Stuart Ballard <stuart.ballard@corp.fast.net>
* java/util/HashMap.java (putAll): Use Iterator hasNext() method.
(putAllInternal): Likewise.
* java/util/Hashtable.java (putAll): Use Iterator hasNext() method.
(putAllInternal): Likewise.
2003-11-26 Michael Koch <konqueror@gmx.de> 2003-11-26 Michael Koch <konqueror@gmx.de>
* java/net/URLStreamHandler.java * java/net/URLStreamHandler.java
......
...@@ -381,8 +381,7 @@ public class HashMap extends AbstractMap ...@@ -381,8 +381,7 @@ public class HashMap extends AbstractMap
public void putAll(Map m) public void putAll(Map m)
{ {
Iterator itr = m.entrySet().iterator(); Iterator itr = m.entrySet().iterator();
int msize = m.size(); while (itr.hasNext())
while (msize-- > 0)
{ {
Map.Entry e = (Map.Entry) itr.next(); Map.Entry e = (Map.Entry) itr.next();
// Optimize in case the Entry is one of our own. // Optimize in case the Entry is one of our own.
...@@ -709,10 +708,10 @@ public class HashMap extends AbstractMap ...@@ -709,10 +708,10 @@ public class HashMap extends AbstractMap
void putAllInternal(Map m) void putAllInternal(Map m)
{ {
Iterator itr = m.entrySet().iterator(); Iterator itr = m.entrySet().iterator();
int msize = m.size(); size = 0;
size = msize; while (itr.hasNext())
while (msize-- > 0)
{ {
size++;
Map.Entry e = (Map.Entry) itr.next(); Map.Entry e = (Map.Entry) itr.next();
Object key = e.getKey(); Object key = e.getKey();
int idx = hash(key); int idx = hash(key);
......
...@@ -510,7 +510,7 @@ public class Hashtable extends Dictionary ...@@ -510,7 +510,7 @@ public class Hashtable extends Dictionary
{ {
Iterator itr = m.entrySet().iterator(); Iterator itr = m.entrySet().iterator();
for (int msize = m.size(); msize > 0; msize--) while (itr.hasNext())
{ {
Map.Entry e = (Map.Entry) itr.next(); Map.Entry e = (Map.Entry) itr.next();
// Optimize in case the Entry is one of our own. // Optimize in case the Entry is one of our own.
...@@ -859,11 +859,11 @@ public class Hashtable extends Dictionary ...@@ -859,11 +859,11 @@ public class Hashtable extends Dictionary
void putAllInternal(Map m) void putAllInternal(Map m)
{ {
Iterator itr = m.entrySet().iterator(); Iterator itr = m.entrySet().iterator();
int msize = m.size(); size = 0;
this.size = msize;
for (; msize > 0; msize--) while (itr.hasNext())
{ {
size++;
Map.Entry e = (Map.Entry) itr.next(); Map.Entry e = (Map.Entry) itr.next();
Object key = e.getKey(); Object key = e.getKey();
int idx = hash(key); int idx = hash(key);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment