struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 11394] New: - logic:iterate uses a slow copy method for native arrays
Date Thu, 01 Aug 2002 23:54:48 GMT
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: struts-dev@jakarta.apache.org
        ReportedBy: Eric.D.Friedman@wellsfargo.com


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:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message