Subj : Re: Fwd: Rhino, Changes to JavaMembers.java To : netscape.public.mozilla.jseng From : Attila Szegedi Date : Fri Feb 25 2005 07:02 pm On Thu, 17 Feb 2005 16:34:42 +0100, Igor Bukanov wrote: > > It would not work like that since getIds is used by external > applications. So you would need to implement getIds in terms of the new > interface as well. Or rather provide a default implementation of the new method (Iterator iterator()?) in terms of getIds(). Arrays and similar objects could override iterator() to return a more efficient implementation. BTW, where I see this better than generating an array of IDs up front - what getId() does - is - memory footprint: you need to instantiate one ID at a time instead of 100 000 for a 100 000 element list - break statements. If the for() breaks in the 40th element of a 100 000 list, you only had to generate 40 numeric IDs. > So it is a lot of code just to optimize not that often used > construction. Plus again, do you really think it would optimize the > enumeration by any noticeable margin? > In time, no - you need to create the same number of ID objects. The additional overhead of AASTORE instructions to populate the array with those ID objects is probably negligable :-) Actually, there is a time advantage if the for loop is break-ed, as then the iterator will create less object. In memory burden, yes -- only one ID object needs to exist at any one time. I'd say it's worth a RFE in Bugzilla if the original poster really wants it :-) Attila. .