harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jimmy,Jing Lv" <firep...@gmail.com>
Subject Re: [classlib][luni] java/util/ArrayList.java duplicate code?
Date Wed, 21 May 2008 07:08:40 GMT
Hi Jim,

     It sounds reasonable to me.
     Running the Harmony tests shows no bug and I've apply this fix,
please verify.


2008/5/21 Jim Yu <junjie0122@gmail.com>:
> Hi, all,
>
> I have taken a look at the patch in HARMONY-5799 and noticed the
> following lines in ArrayList.java, growForInsert method(line 407):
>
>   [1] if (location < size / 2) {
>            int newFirst = newArray.length - (size + required);
>            // Copy elements after location to the new array skipping
> inserted elements
>            System.arraycopy(array, location + firstIndex, newArray,
> location + increment,
>                    size - location);
>            // Copy elements before location to the new array from
> firstIndex
>            System.arraycopy(array, firstIndex, newArray, newFirst,
> location);
>            firstIndex = newFirst;
>            lastIndex = newArray.length;
>        } else {
>            System.arraycopy(array, firstIndex, newArray, 0, location);
>            System.arraycopy(array, location + firstIndex, newArray,
> location + required,
>                    size - location);
>            firstIndex = 0;
>            lastIndex = size + required;
>        }
>
> Whether the location is less than size / 2 or not will only affect the
> allocation of elements in the new array.
> The first case relates to leaving the additional space (when increment is
> larger than required)which size is
> increment minus required to be at the top of the new array while the second
> case relates to leaving it at the bottom.
> There are two callers which will call growForInsert method. But none of them
> will utilize the different allocation
> methods mentioned above. If the allocation methods don't make sense, it will
> only produce duplicate code. I just use
> one allocation method and find it works fine. I raised a JIRA at
> https://issues.apache.org/jira/browse/HARMONY-5834.
>
> --
> Best Regards,
> Jim, Jun Jie Yu
>
> China Software Development Lab, IBM
>



-- 

Best Regards!

Jimmy, Jing Lv
China Software Development Lab, IBM

Mime
View raw message