You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by GitBox <gi...@apache.org> on 2022/05/26 13:54:57 UTC

[GitHub] [sling-org-apache-sling-resourceresolver] reschke commented on a diff in pull request #69: SLING-11328: reduce overhead when paths are duplicates + add diagnostics

reschke commented on code in PR #69:
URL: https://github.com/apache/sling-org-apache-sling-resourceresolver/pull/69#discussion_r882696412


##########
src/main/java/org/apache/sling/resourceresolver/impl/mapping/MapEntries.java:
##########
@@ -1077,25 +1077,28 @@ private void gather(final ResourceResolver resolver, final List<MapEntry> entrie
      */
     private boolean addEntry(final Map<String, List<MapEntry>> entryMap, final String key, final MapEntry entry) {
 
-        if (entry==null){
+        if (entry == null) {
+            log.trace("trying to add null entry for {}", key);
             return false;
-        }
-
-        List<MapEntry> entries = entryMap.get(key);
-        if (entries == null) {
-            entries = new ArrayList<>();
-            entries.add(entry);
-            // and finally sort list
-            Collections.sort(entries);
-            entryMap.put(key, entries);
         } else {
-            List<MapEntry> entriesCopy =new ArrayList<>(entries);
-            entriesCopy.add(entry);
-            // and finally sort list
-            Collections.sort( entriesCopy);
-            entryMap.put(key, entriesCopy);
+            List<MapEntry> entries = entryMap.get(key);
+            if (entries == null) {
+                entries = new ArrayList<>();
+                entries.add(entry);
+                entryMap.put(key, Collections.synchronizedList(entries));

Review Comment:
   Good point. Will paddle back and just leave in the log messages.



-- 
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: dev-unsubscribe@sling.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org