Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 23865 invoked from network); 5 Aug 2010 07:25:43 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 5 Aug 2010 07:25:43 -0000 Received: (qmail 86976 invoked by uid 500); 5 Aug 2010 07:25:42 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 86682 invoked by uid 500); 5 Aug 2010 07:25:39 -0000 Mailing-List: contact dev-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list dev@harmony.apache.org Received: (qmail 86673 invoked by uid 99); 5 Aug 2010 07:25:38 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Aug 2010 07:25:38 +0000 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=FREEMAIL_FROM,HTML_MESSAGE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of prashanth.jayashree@gmail.com designates 74.125.82.43 as permitted sender) Received: from [74.125.82.43] (HELO mail-ww0-f43.google.com) (74.125.82.43) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 05 Aug 2010 07:25:31 +0000 Received: by wwb22 with SMTP id 22so1916670wwb.0 for ; Thu, 05 Aug 2010 00:25:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=D2j9zXLSd5muV11uVAyM1O0wOP4Ecv4fLTCOSwBj+Dk=; b=Pv4w4yYACx3DvveWzQkzdNs53UG7vSVJKSWLPXGpzqkWY6WOhM19YU914VvkgW78EH srKaQTnHBLGEzh1YTWVb9nLYxM/QV6yeACWmca8fVVJnGcp+5Gvh+dGObSBMd2Pxon+x uQO6FdeCyufzF7kwS1i+PuZkp56Nc786d6Vyk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=NHht56aeXG+Es1JhNZjMi4NhnJkDm3iHwaRiT+vwPoMv8W0THEstoDXta51SnpZT/x 1UogpQlaSzQnDPR557NCmakKletE81SLZF5VMjMJPN/7IJgl9vwSX59HlLyLmr1yPSTu pH5eHucRxEOjUmVsCJxDTaYWjsP/3NMVeIJoI= MIME-Version: 1.0 Received: by 10.227.157.13 with SMTP id z13mr8653755wbw.184.1280993111636; Thu, 05 Aug 2010 00:25:11 -0700 (PDT) Received: by 10.227.150.154 with HTTP; Thu, 5 Aug 2010 00:25:11 -0700 (PDT) In-Reply-To: <4C598D8D.4010404@googlemail.com> References: <4C56E4F8.2040105@googlemail.com> <8652591182674059221@unknownmsgid> <201008041456.o74EuNhO004999@d12av03.megacenter.de.ibm.com> <4C598D8D.4010404@googlemail.com> Date: Thu, 5 Aug 2010 12:55:11 +0530 Message-ID: Subject: Re: [classlib][luni] Collections classes - code reviews and optimisations From: Prashanth K S To: dev@harmony.apache.org Content-Type: multipart/alternative; boundary=0016368332f460fe63048d0e73e6 X-Virus-Checked: Checked by ClamAV on apache.org --0016368332f460fe63048d0e73e6 Content-Type: text/plain; charset=UTF-8 I felt the same with the growth factor. We have a field called increment in the grow methods which is set to 12 in most of the cases, attributing to the excessive growth. Not sure how/why 12 was chosen. -- Regards Prashanth On Wed, Aug 4, 2010 at 9:25 PM, Oliver Deakin wrote: > On 04/08/2010 15:56, Mark Hindess wrote: > >> I've now refactored the exception code to the start of the methods and >> shuffled some of the if else cases around a little. >> >> Next I plan to look at: >> >> 1) remove the following from addAll(...): >> >> if (this == collection) { >> collection = (ArrayList)clone(); >> } >> >> since it is immediately followed by a call to collection.toArray() so >> it should be unnecessary. >> >> 2) Change the fields to firstIndex and size. >> >> In message >> >, >> Catherine Hope writes: >> >>> I did some analysis on what API methods access others between the RI >>> and Harmony (by subclassing ArrayList and adding some trace) to answer >>> a couple of the review points. >>> >> Thanks Cath. I wonder if we can use serialization/deserialization >> to figure out how the RI grows the capacity of the ArrayList. Our >> implementation seems to grow it quite quickly. >> >> The differences I found were: >>> - RI contains(Object) calls indexOf(Object), so we could also do this >>> to reduce the code duplication >>> >> Sounds good. >> > > +1 > > > - RI add(Object), add(int, Object), addAll(Collection), addAll(int, >>> Collection) use ensureCapacity(int) >>> >> Interesting. Makes our three grow* methods seems a little excessive. >> > > I was just thinking the same thing :) > > It occurs to me that the grow methods for the start and end of the list are > just special cases of growForInsert(). I think we could probably roll them > all into one neater method covering all three cases. This should remove the > necessity to check if we are at the start/end of the array in the add > methods too - when we return from growForInsert() we will know that there > will be the required number of empty slots at location and that > first/lastIndex have been updated, so we can then just write our data > straight into that position. > > > > - RI remove(Object) doesn't reference indexOf(Object) and remove(int) - >>> though I don't think this would save anything if we changed it >>> >> Agreed. >> > +1 > > Regards, > Oliver > > -Mark. >> >> >> >> > -- > Oliver Deakin > Unless stated otherwise above: > IBM United Kingdom Limited - Registered in England and Wales with number > 741598. > Registered office: PO Box 41, North Harbour, Portsmouth, Hampshire PO6 3AU > > --0016368332f460fe63048d0e73e6--