File tree Expand file tree Collapse file tree
recaf-core/src/main/java/software/coley/recaf/services/inheritance Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ sealed interface ClassPathNodeProvider {
1414 @ Nullable
1515 ClassPathNode getNode (@ Nonnull String name );
1616
17- static ClassPathNodeProvider cache (Workspace workspace ) {
17+ static ClassPathNodeProvider . Cached cache (Workspace workspace ) {
1818 Stream <ClassPathNode > stream = workspace .classesStream ();
1919 Map <String , ClassPathNode > nodes = new HashMap <>(4096 );
2020 stream .forEach (classPathNode -> {
@@ -32,6 +32,10 @@ public ClassPathNode getNode(@Nonnull String name) {
3232 }
3333
3434 record Cached (Map <String , ClassPathNode > nodes ) implements ClassPathNodeProvider {
35+ int size () {
36+ return nodes .size ();
37+ }
38+
3539 @ Nullable
3640 @ Override
3741 public ClassPathNode getNode (@ Nonnull String name ) {
Original file line number Diff line number Diff line change @@ -113,8 +113,8 @@ private void refreshChildLookup() {
113113 parentToChild .clear ();
114114
115115 // Repopulate
116- Set < ClassInfo > visited = Collections . newSetFromMap ( new IdentityHashMap <>( 16384 ) );
117- ClassPathNodeProvider nodeProvider = ClassPathNodeProvider . cache ( workspace );
116+ ClassPathNodeProvider . Cached nodeProvider = ClassPathNodeProvider . cache ( workspace );
117+ Set < ClassInfo > visited = Collections . newSetFromMap ( new IdentityHashMap <>( nodeProvider . size () + 1024 /* leeway */ ) );
118118 workspace .forEachClass (false , cls -> {
119119 populateParentToChildLookup (cls , visited , nodeProvider );
120120 });
You can’t perform that action at this time.
0 commit comments