mbien commented on code in PR #9834:
URL: https://github.com/apache/netbeans/pull/9834#discussion_r4744052295


##########
ide/projectui/src/org/netbeans/modules/project/ui/ProjectsRootKeys.java:
##########
@@ -111,15 +124,21 @@ Collection<PrjInfo> getKeys() {
             var nestedSize = nested.size();
             nestedArr[0] = nestedSize;
 
-            var p = new ProjectsRootKeys.PrjInfo(prj, type, nestedArr);
-            nested.add(prj.getProjectDirectory());
-            dirs.add(p);
-            snapshot.put(prj, p);
+            PrjInfo parent = nested.isEmpty() ? null : nested.peekLast();
+            PrjInfo info = new ProjectsRootKeys.PrjInfo(prj, type, nestedArr);
+            nested.add(info);
+            var children = parentship.get(parent);
+            if (children == null) {
+                children = new TreeSet<>(byProjectDisplayName);
+                parentship.put(parent, children);
+            }
+            children.add(info);

Review Comment:
   > my reply is built on 10+ years of working on JVM compilers
   
   your reply to my code simplification comment was, and i quote:
   
   > I tried to use the “lambda style”, but then resorted back to old good if…
   
   thats it. I could guess what this meant but tbh I didn't really know. It 
sounded like you tried to implement it but then _something_ happened and you 
reverted - i have no crystal ball. I pasted a snippet and tried again. You 
edited the post afterwards.
   
   <img width="618" height="169" alt="image" 
src="https://github.com/user-attachments/assets/201fdc79-709a-4d13-abc7-ac233d1c9658";
 />
   
   This clarifies your comment. You don't care about code simplifications as 
long you can still read it.
   
   Regarding performance: firstly this was not the _reason_ I posted the 
comment, secondly: benchmarking this in a micro benchmark is almost pointless 
here since the situation changes based on how the hash code is computed, if the 
lambda actually captures anything and what path is actually the hot path (e.g 
in caches data wouldn't be absent anymore after a while). But I actually 
collect JMH benchmarks, so if you come up with one for Maps which I don't have 
yet, please share.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to