joerghoh commented on code in PR #236:
URL:
https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/236#discussion_r4222299853
##########
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java:
##########
@@ -1148,17 +1148,14 @@ public boolean hasChildren(Resource resource) {
@Override
public String getParentResourceType(final Resource resource) {
checkClosed();
- String resourceSuperType = null;
- if (resource != null) {
- if (parentResourceTypeMap.containsKey(resource.getPath())) {
- resourceSuperType =
-
parentResourceTypeMap.get(resource.getPath()).orElse(null);
- } else {
- resourceSuperType = getParentResourceTypeInternal(resource);
- parentResourceTypeMap.put(resource.getPath(),
Optional.ofNullable(resourceSuperType));
- }
+ if (resource == null) {
+ return null;
}
- return resourceSuperType;
+ final ResourceTypeInformation key =
+ new ResourceTypeInformation(resource.getResourceType(),
resource.getResourceSuperType(), null);
+ return parentResourceTypeMap
+ .computeIfAbsent(key, k ->
Optional.ofNullable(getParentResourceTypeInternal(resource)))
+ .orElse(null);
Review Comment:
``JcrNodeResource.getResourceSuperType`` is indeed just the read of a
property of an existing property (directly via the Jcr API); could probably be
optimized a bit (reading from the Resource's ValueMap instead).
will give a try and see if it's getting simpler.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]