Joerg Hoh created SLING-11558: --------------------------------- Summary: [Performance] Remove resource -> path -> resource conversion Key: SLING-11558 URL: https://issues.apache.org/jira/browse/SLING-11558 Project: Sling Issue Type: Improvement Components: Servlets Affects Versions: Servlets Resolver 2.9.8 Reporter: Joerg Hoh
Currently the [ResourceCollector|https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/helper/ResourceCollector.java] uses the [LocationIterator|https://github.com/apache/sling-org-apache-sling-servlets-resolver/blob/master/src/main/java/org/apache/sling/servlets/resolver/internal/helper/LocationIterator.java] to build a list of possible locations where the script for a resource type can be located. The interface is based on Strings (representing a repository path), although both within the LocationIterator and in the ResourceCollector Resources are used. * The mapping of a path to a string requires a repository access, thus accessing the repo twice (checking in the LocationIterator if a resource exists at a certain path, plus conversion of that path again into a resource in the ResourceCollector) is redundant. Instead the LocationIterator should just return resources instead of the paths to resources. * The LocationIterator implements the {{Iterator}} interface, although it is only used in the ResourceCollector, which just iterates over all entries in a single loop. The LocationIterator could just return a collection of Resources (not implementing the Iterator interface), which makes the logic in this class much cleaner. -- This message was sent by Atlassian Jira (v8.20.10#820010)