Skip to content

Commit dac849a

Browse files
use same Branch.Factory instance for all nodes, inline createRoot
1 parent 3c91668 commit dac849a

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

enigma/src/main/java/org/quiltmc/enigma/util/multi_trie/CompositeStringMultiTrie.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,21 +48,14 @@ public static <V> CompositeStringMultiTrie<V> of(
4848
return new CompositeStringMultiTrie<>(branchesFactory, leavesFactory);
4949
}
5050

51-
private static <V> Root<V> createRoot(
52-
Supplier<Map<Character, Branch<V>>> branchesFactory,
53-
Supplier<Collection<V>> leavesFactory
54-
) {
55-
return new Root<>(
56-
branchesFactory.get(), leavesFactory.get(),
57-
new Branch.Factory<>(leavesFactory, branchesFactory)
58-
);
59-
}
60-
6151
private CompositeStringMultiTrie(
6252
Supplier<Map<Character, Branch<V>>> childrenFactory,
6353
Supplier<Collection<V>> leavesFactory
6454
) {
65-
this.root = createRoot(childrenFactory, leavesFactory);
55+
this.root = new Root<>(
56+
childrenFactory.get(), leavesFactory.get(),
57+
new Branch.Factory<>(leavesFactory, childrenFactory)
58+
);
6659
}
6760

6861
@Override
@@ -181,7 +174,7 @@ CompositeStringMultiTrie.Branch<V> create(
181174
) {
182175
return new CompositeStringMultiTrie.Branch<>(
183176
parent, key, this.leavesFactory.get(), this.branchesFactory.get(),
184-
new CompositeStringMultiTrie.Branch.Factory<>(this.leavesFactory, this.branchesFactory)
177+
this
185178
);
186179
}
187180
}

0 commit comments

Comments
 (0)