AbstractMap.java (putAll): Use entrySet size.

* java/util/AbstractMap.java (putAll): Use entrySet size.
	(toString): Explicitly use getKey() and getValue().

From-SVN: r52008
This commit is contained in:
Mark Wielaard 2002-04-08 00:23:28 +00:00 committed by Mark Wielaard
parent 298f6e4bdc
commit ecc2337579
2 changed files with 10 additions and 5 deletions

View File

@ -1,3 +1,8 @@
2002-04-07 Mark Wielaard <mark@klomp.org>
* java/util/AbstractMap.java (putAll): Use entrySet size.
(toString): Explicitly use getKey() and getValue().
2002-04-07 Mark Wielaard <mark@klomp.org>
* java/util/Hashtable.java (contains): Remove NullPointer check.

View File

@ -353,7 +353,7 @@ public abstract class AbstractMap implements Map
public void putAll(Map m)
{
Iterator entries = m.entrySet().iterator();
int pos = size();
int pos = m.size();
while (--pos >= 0)
{
Map.Entry entry = (Map.Entry) entries.next();
@ -425,10 +425,10 @@ public abstract class AbstractMap implements Map
StringBuffer r = new StringBuffer("{");
for (int pos = size(); pos > 0; pos--)
{
// Append the toString value of the entries rather than calling
// getKey/getValue. This is more efficient and it matches the JDK
// behaviour.
r.append(entries.next());
Map.Entry entry = (Map.Entry) entries.next();
r.append(entry.getKey());
r.append('=');
r.append(entry.getValue());
if (pos > 1)
r.append(", ");
}