From eb1e64ef807d81c18cc82c3b1979f44525c9e3d2 Mon Sep 17 00:00:00 2001 From: Bryce McKinlay Date: Sun, 7 Dec 2003 21:03:49 +0000 Subject: [PATCH] Hashtable.java (internalContainsValue): Removed. * java/util/Hashtable.java (internalContainsValue): Removed. (containsValue): Don't delegate to internalContainsValue. From-SVN: r74399 --- libjava/ChangeLog | 5 +++ libjava/java/util/Hashtable.java | 57 ++++++++++---------------------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 78b8c59abba..98210397a62 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,8 @@ +2002-12-08 Bryce McKinlay + + * java/util/Hashtable.java (internalContainsValue): Removed. + (containsValue): Don't delegate to internalContainsValue. + 2003-12-06 Michael Koch * javax/naming/directory/Attribute.java, diff --git a/libjava/java/util/Hashtable.java b/libjava/java/util/Hashtable.java index d19b2fbbc81..9cfa925762a 100644 --- a/libjava/java/util/Hashtable.java +++ b/libjava/java/util/Hashtable.java @@ -333,11 +333,22 @@ public class Hashtable extends Dictionary */ public synchronized boolean contains(Object value) { - /* delegate to non-overridable worker method - * to avoid blowing up the stack, when called - * from overridden contains[Value]() method. - */ - return internalContainsValue(value); + for (int i = buckets.length - 1; i >= 0; i--) + { + HashEntry e = buckets[i]; + while (e != null) + { + if (value.equals(e.value)) + return true; + e = e.next; + } + } + + // Must throw on null argument even if the table is empty + if (value == null) + throw new NullPointerException(); + + return false; } /** @@ -354,43 +365,11 @@ public class Hashtable extends Dictionary */ public boolean containsValue(Object value) { - /* delegate to older method to make sure code overwriting it - * continues to work. - */ + // Delegate to older method to make sure code overriding it continues + // to work. return contains(value); } - /** - * Returns true if this Hashtable contains a value o, such that - * o.equals(value). This is an internal worker method - * called by contains() and containsValue(). - * - * @param value the value to search for in this Hashtable - * @return true if at least one key maps to the value - * @see #contains(Object) - * @see #containsKey(Object) - * @throws NullPointerException if value is null - */ - private boolean internalContainsValue(Object value) - { - for (int i = buckets.length - 1; i >= 0; i--) - { - HashEntry e = buckets[i]; - while (e != null) - { - if (value.equals(e.value)) - return true; - e = e.next; - } - } - - // Must throw on null argument even if the table is empty - if (value == null) - throw new NullPointerException(); - - return false; - } - /** * Returns true if the supplied object equals() a key * in this Hashtable.