You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Joerg Hoh (Jira)" <ji...@apache.org> on 2023/06/10 16:20:00 UTC

[jira] [Commented] (SLING-11558) [Performance] Remove resource -> path -> resource conversion

    [ https://issues.apache.org/jira/browse/SLING-11558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17731227#comment-17731227 ] 

Joerg Hoh commented on SLING-11558:
-----------------------------------

2nd PR: https://github.com/apache/sling-org-apache-sling-servlets-resolver/pull/37

> [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
>          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)