neilcsmith-net commented on code in PR #9834:
URL: https://github.com/apache/netbeans/pull/9834#discussion_r4737964916
##########
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:
> ... there is no performance aspect I can think of where the
computeIfAbsent variant would be more performant.
Very expensive hash code! :laughing: There's certainly potential for
performance improvement when other operations can be optimized or
short-circuited. There's certainly no hard and fast rule either way without
contextual information.
TL;DR - Merged code looks fine to me. (aside from `var` which makes
reviewing harder).
--
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