DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11394>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=11394

logic:iterate uses a slow copy method for native arrays

           Summary: logic:iterate uses a slow copy method for native arrays
           Product: Struts
           Version: 1.1 Beta 1
          Platform: All
        OS/Version: Other
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Custom Tags
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


When given a native language array, the logic:iterate class wraps it in an 
ArrayList so that it can use an Iterator for the list traversal.  
Unfortunately, it uses the slowest possible means to copy the array into a list 
(see below).

Better would be to simply use java.util.Arrays.asList(collection).  This method 
returns a read-only List implementation that is backed by the "real" array, and 
so no copy is made.  Thus, the List can be made in constant time rather than in 
linear time as is currently required.

This is the slow code:

// Construct an iterator for this collection
if (collection.getClass().isArray()) {
    int length = Array.getLength(collection);
    ArrayList c = new ArrayList(length);
    for (int i = 0; i < length; i++) {
        c.add(Array.get(collection, i));
    }
    iterator = c.iterator();

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to