[ 
https://issues.apache.org/jira/browse/SLING-11558?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Joerg Hoh resolved SLING-11558.
-------------------------------
    Resolution: Fixed

> [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
>            Assignee: Joerg Hoh
>            Priority: Major
>             Fix For: Servlets Resolver 2.9.14
>
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to