ElementImpl.getBaseURI has unnecessary long execution time if the depth of the 
node to the document root is longer
------------------------------------------------------------------------------------------------------------------

                 Key: XERCESJ-1424
                 URL: https://issues.apache.org/jira/browse/XERCESJ-1424
             Project: Xerces2-J
          Issue Type: Improvement
          Components: DOM (Level 3 Core)
    Affects Versions: 2.9.1
            Reporter: Ludger Bünger
            Priority: Minor


When calling getBaseURI upon an ElementImpl, an overproportionally long amount 
of time (~90% for my specific setup) is spent inside constructor calls of 
Xerces' URI class.
Most of the time inside URI construction is spent for URI validation (which is 
necessary).

getBaseURI works as follows:

1) if a xml base attribute is given:
a) validate the correctness of this base URI by constructing an instance of URI
b) and return it's toString() value.

2) if no xml base attribute is given (the most common case):
a) retrieve the base uri (using a recursive call to getBaseURI) from my parent 
(more precise: my owner node),
b) validate the correctness of this base URI by constructing an instance of URI
c) and return it's toString() value.


As we can see, each call to to ownerNode.getBaseURI does an URI verification.
Since this method is called recursively upon an element's parent, this is done 
once per recursion level of the given element if the base uri has been set upon 
the document root and thus unnecessary often.

So step 2b) is a hotspot and completely unnecessary since we can be sure that 
the base uri already retrieved from another node has been already validated.
This is also documented inside the ElementImpl.getBaseURI sources:

Quote from source:

catch (org.apache.xerces.util.URI.MalformedURIException ex) {
   // This should never happen: parent should have checked the URI and returned 
null if invalid.
   return null;
}

So the performance fix is easy:

remove validation of a parent's baseURI.

See attached patch.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to