You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Jim Yu (JIRA)" <ji...@apache.org> on 2008/05/21 05:30:55 UTC
[jira] Created: (HARMONY-5834) [classlib][luni] ArrayList
growForInsert method code optimization
[classlib][luni] ArrayList growForInsert method code optimization
-----------------------------------------------------------------
Key: HARMONY-5834
URL: https://issues.apache.org/jira/browse/HARMONY-5834
Project: Harmony
Issue Type: Improvement
Components: Classlib
Affects Versions: 5.0M6
Reporter: Jim Yu
Fix For: 5.0M6
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.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Resolved: (HARMONY-5834) [classlib][luni] ArrayList
growForInsert method code optimization
Posted by "Jimmy, Jing Lv (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jimmy, Jing Lv resolved HARMONY-5834.
-------------------------------------
Resolution: Fixed
Hi,
The fix is fine, committed at r658561, please verify.
> [classlib][luni] ArrayList growForInsert method code optimization
> -----------------------------------------------------------------
>
> Key: HARMONY-5834
> URL: https://issues.apache.org/jira/browse/HARMONY-5834
> Project: Harmony
> Issue Type: Improvement
> Components: Classlib
> Affects Versions: 5.0M6
> Reporter: Jim Yu
> Assignee: Jimmy, Jing Lv
> Fix For: 5.0M6
>
> Attachments: HARMONY-5834.diff
>
>
> 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.
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Assigned: (HARMONY-5834) [classlib][luni] ArrayList
growForInsert method code optimization
Posted by "Jimmy, Jing Lv (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jimmy, Jing Lv reassigned HARMONY-5834:
---------------------------------------
Assignee: Jimmy, Jing Lv
> [classlib][luni] ArrayList growForInsert method code optimization
> -----------------------------------------------------------------
>
> Key: HARMONY-5834
> URL: https://issues.apache.org/jira/browse/HARMONY-5834
> Project: Harmony
> Issue Type: Improvement
> Components: Classlib
> Affects Versions: 5.0M6
> Reporter: Jim Yu
> Assignee: Jimmy, Jing Lv
> Fix For: 5.0M6
>
> Attachments: HARMONY-5834.diff
>
>
> 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.
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (HARMONY-5834) [classlib][luni] ArrayList
growForInsert method code optimization
Posted by "Jim Yu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jim Yu updated HARMONY-5834:
----------------------------
Attachment: HARMONY-5834.diff
> [classlib][luni] ArrayList growForInsert method code optimization
> -----------------------------------------------------------------
>
> Key: HARMONY-5834
> URL: https://issues.apache.org/jira/browse/HARMONY-5834
> Project: Harmony
> Issue Type: Improvement
> Components: Classlib
> Affects Versions: 5.0M6
> Reporter: Jim Yu
> Fix For: 5.0M6
>
> Attachments: HARMONY-5834.diff
>
>
> 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.
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (HARMONY-5834) [classlib][luni] ArrayList
growForInsert method code optimization
Posted by "Jim Yu (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/HARMONY-5834?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jim Yu closed HARMONY-5834.
---------------------------
> [classlib][luni] ArrayList growForInsert method code optimization
> -----------------------------------------------------------------
>
> Key: HARMONY-5834
> URL: https://issues.apache.org/jira/browse/HARMONY-5834
> Project: Harmony
> Issue Type: Improvement
> Components: Classlib
> Affects Versions: 5.0M6
> Reporter: Jim Yu
> Assignee: Jimmy, Jing Lv
> Fix For: 5.0M6
>
> Attachments: HARMONY-5834.diff
>
>
> 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.
>
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.