classpath-patches
[Top][All Lists]
Advanced

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

[cp-patches] RFC: Hashtable cleanup


From: Roman Kennke
Subject: [cp-patches] RFC: Hashtable cleanup
Date: Tue, 10 Jan 2006 15:52:32 +0000

Hi there,

I would like to propose the following patch that was written by my
collegue Fridjof. Basically, it replaces the parameterized Iterator and
Enumerator classes with normal classes for values/entries/keys. The
EntryIterator and EntryEnumerator are just like the previous
HashIterator and Enumerator, the other two versions are small classes
derived from these two, that only return the key vs. values.

Not only is that a cleaner OO design (IMO), it improves analyzability by
data flow analysis tools, which can not (always) handle parameterized
classes very well.

Note that this also includes a small improvement in the rehash() method.
See the ChangeLog and the code for details.

So, should I check this in?

2006-01-10  Roman Kennke  <address@hidden>

        Reported by: Fridjof Siebert <address@hidden>
        * java/util/Hashtable.java
        (KEYS): Removed unneeded field.
        (VALUES): Removed unneeded field.
        (ENTRIES): Removed unneeded field.
        (keys): Return a KeyEnumerator instance.
        (elements): Returns a ValueEnumerator instance.
        (toString): Use an EntryIterator instance.
        (keySet): Return a KeyIterator instance.
        (values): Return a ValueIterator instance.
        (entrySet): Return an EntryIterator instance.
        (hashCode): Use EntryIterator instance.
        (rehash): Changed this loop to avoid redundant reads and make
        it obvious that null checking is not needed.
        (writeObject): Use EntryIterator instance.
        (HashIterator): Removed class.
        (Enumerator): Removed class.
        (EntryIterator): New class.
        (KeyIterator): New class.
        (ValueIterator): New class.
        (EntryEnumerator): New class.
        (KeyEnumerator): New class.
        (ValueEnumerator): New class.


Cheers, Roman

Attachment: patch.diff
Description: Text Data


reply via email to

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