|
Quick Lists
|
|
Bug ID:
|
6267067
|
|
Votes
|
0
|
|
Synopsis
|
Improve List.reverse for singletons
|
|
Category
|
java:compiler
|
|
Reported Against
|
|
|
Release Fixed
|
mustang(b92)
|
|
State
|
10-Fix Delivered,
Verified,
request for enhancement
|
|
Priority:
|
2-High
|
|
Related Bugs
|
|
|
Submit Date
|
08-MAY-2005
|
|
Description
|
List.reverse could detect a singleton list and return itself, thereby avoiding
an unnecesary customer creation for the new list.
xxxxx@xxxxx 2005-05-08 20:43:58 GMT
|
|
Work Around
|
N/A
|
|
Evaluation
|
Both empty and singleton lists can be returned unchanged by reverse.
However, there is one gotcha that needs to be addressed with this fix. List.prependList assumes that reverse always returns a new list, because it reuses the List objects by zapping their tail pointer, rather than creating new objects. The workaround for that is simple: prependList already checks for either list being empty, so it is simply necessary to also check if the list being prepended is a singleton, and handle that case directly.
There appear to be no other problem cases for reverse() in javac.
Posted Date : 2006-07-14 23:11:28.0
|
|
Comments
|
PLEASE NOTE: JDK6 is formerly known as Project Mustang
|
|
|
 |