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=4432>.
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=4432

org.apache.xerces.dom.DeferredDocumentImpl.getNodeValueString() very slow for large 
node values.

           Summary: org.apache.xerces.dom.DeferredDocumentImpl.getNodeValueS
                    tring() very slow for large node values.
           Product: Xerces-J
           Version: 1.4.3
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


Try to call the function 
org.apache.xerces.dom.DeferredDocumentImpl.getNodeValueString() for a node 
containing a large text (>100Kb). The response time is O(n*n), where n is the 
text's size.
The problem is the statement: 
str.insert(0, fStringPool.toString(valueIndex));

Explanation:
Every time a new chunk is inserted in the first position, the entire content is 
shifted to the right. This makes the approach O(n*n).

Fixing suggestion:
Store all chunks into a temporary structure (String[] or Stack) first, and then  
append them in the StringBuffer in reversed order. This is O(n), and makes a 
huge difference for large strings (mine has 2MB).

Note: This problem is more often seen when using SOAP. There are lots of 
complains in the SOAP mailing list related to this problem.

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

Reply via email to