Improve JcrResourceResolver#resolve performance
-----------------------------------------------
Key: SLING-2239
URL: https://issues.apache.org/jira/browse/SLING-2239
Project: Sling
Issue Type: Improvement
Components: JCR
Reporter: Antonio Sanso
Priority: Minor
The JcrResourceResolver#resolve might be improved performance wise.
For example in certain situations the complexity is linear with the number of
children nodes:
private Resource resolveInternal(String absPath) {
..
// no direct resource found, so we have to drill down into the
// resource tree to find a match
resource = getResourceInternal("/");
StringBuilder resolutionPath = new StringBuilder();
StringTokenizer tokener = new StringTokenizer(absPath, "/");
while (resource != null && tokener.hasMoreTokens()) {
String childNameRaw = tokener.nextToken();
Resource nextResource = getChildInternal(resource,
childNameRaw);
...
and
private Resource getChildInternal(Resource parent, String childName) {
...
// we do not have a child with the exact name, so we look for
// a child, whose alias matches the childName
Iterator<Resource> children = listChildren(parent);
while (children.hasNext()) {
child = children.next();
String[] aliases = getProperty(child, PROP_ALIAS, String[].class);
here for example a search can be done in order to check if any sling:alias
exists before to go and iterate the loop or better iterate just the node having
the alias property.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira