thomasmueller commented on code in PR #2065:
URL: https://github.com/apache/jackrabbit-oak/pull/2065#discussion_r1948536411


##########
oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/mount/SimpleMountInfoProvider.java:
##########
@@ -18,47 +18,50 @@
  */
 package org.apache.jackrabbit.oak.spi.mount;
 
+import org.jetbrains.annotations.NotNull;
+
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * A simple and inefficient implementation to manage mount points
  */
 final class SimpleMountInfoProvider implements MountInfoProvider {
 
-    private final Map<String, Mount> mounts;
+    private final Map<String, Mount> nameToMounts;

Review Comment:
   For me, "nameToMounts" would mean the key is name, and the value is an 
_array_ of mounts... So I would use "nameToMount". 
   
   ```suggestion
       private final Map<String, Mount> nameToMount;
   ```



##########
oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/mount/SimpleMountInfoProvider.java:
##########
@@ -67,9 +70,9 @@ public boolean hasNonDefaultMounts() {
     }
 
     @Override
-    public Collection<Mount> getMountsPlacedUnder(String path) {
-        Collection<Mount> mounts = new ArrayList<>();
-        for ( Mount mount : this.mounts.values()) {
+    public @NotNull Collection<Mount> getMountsPlacedUnder(String path) {
+        Collection<Mount> mounts = new ArrayList<>(this.mounts.size());

Review Comment:
   If I'm not mistaken, the average size of the result is 1, so actually `new 
ArrayList<>(1);` would be better.
   ```suggestion
           Collection<Mount> mounts = new ArrayList<>(1);
   ```



##########
oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/mount/SimpleMountInfoProvider.java:
##########
@@ -78,9 +81,9 @@ public Collection<Mount> getMountsPlacedUnder(String path) {
     }
 
     @Override
-    public Collection<Mount> getMountsPlacedDirectlyUnder(String path) {
-        Collection<Mount> mounts = new ArrayList<>();
-        for ( Mount mount : this.mounts.values()) {
+    public @NotNull Collection<Mount> getMountsPlacedDirectlyUnder(String 
path) {
+        Collection<Mount> mounts = new ArrayList<>(this.mounts.size());
+        for ( Mount mount : this.mounts) {

Review Comment:
   ```suggestion
           for (Mount mount : this.mounts) {
   ```



##########
oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/mount/SimpleMountInfoProvider.java:
##########
@@ -78,9 +81,9 @@ public Collection<Mount> getMountsPlacedUnder(String path) {
     }
 
     @Override
-    public Collection<Mount> getMountsPlacedDirectlyUnder(String path) {
-        Collection<Mount> mounts = new ArrayList<>();
-        for ( Mount mount : this.mounts.values()) {
+    public @NotNull Collection<Mount> getMountsPlacedDirectlyUnder(String 
path) {
+        Collection<Mount> mounts = new ArrayList<>(this.mounts.size());
+        for ( Mount mount : this.mounts) {
             if ( mount.isDirectlyUnder(path) ) {

Review Comment:
   ```suggestion
           for (Mount mount : this.mounts) {
               if (mount.isDirectlyUnder(path)) {
   ```



##########
oak-core-spi/src/main/java/org/apache/jackrabbit/oak/spi/mount/SimpleMountInfoProvider.java:
##########
@@ -67,9 +70,9 @@ public boolean hasNonDefaultMounts() {
     }
 
     @Override
-    public Collection<Mount> getMountsPlacedUnder(String path) {
-        Collection<Mount> mounts = new ArrayList<>();
-        for ( Mount mount : this.mounts.values()) {
+    public @NotNull Collection<Mount> getMountsPlacedUnder(String path) {
+        Collection<Mount> mounts = new ArrayList<>(this.mounts.size());
+        for ( Mount mount : this.mounts) {

Review Comment:
   ```suggestion
           for (Mount mount : this.mounts) {
   ```



-- 
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]

Reply via email to