classpath
[Top][All Lists]
Advanced

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

[patch] Re: HashMap putAll/putAllInternal bug


From: Stuart Ballard
Subject: [patch] Re: HashMap putAll/putAllInternal bug
Date: Thu, 25 Sep 2003 14:25:57 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3.1) Gecko/20030527 Debian/1.3.1-2

Stuart Ballard wrote:
The HashMap putAll and putAllInternal (called from constructor) methods use size() to get the size of the map to be added, and then iterate over the iterator that many times to add elements. Instead, they should call hasNext() on the iterator.

Attached is a patch to HashMap and Hashtable to fix this issue.

I gave up on trying to fix it for "all" classes when I noticed that ArrayList was actually doing meaningful optimization based on the returned size. It would probably still be worth testing Sun's implementation of all the *List and *Set classes, and Vector, to see how they cope with an inaccurate return from size().

If someone would test and apply this patch, I'd be extremely grateful. (my paperwork was completed years ago, in case it matters - this patch is probably too small to care, anyway). The patch is untested as I've never been able to successfully build Classpath from source.

Thanks,
Stuart.

--
Stuart Ballard, Senior Web Developer
FASTNET - Web Solutions
(215) 283-2300, ext. 126
www.fast.net





reply via email to

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