Skip to content

Commit f2f2b48

Browse files
forketyforkpivovarit
authored andcommitted
Optimized the TreeNode constructor (eugenp#590)
1 parent f73bee2 commit f2f2b48

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.baeldung.threadpool;
22

3-
import java.util.Arrays;
4-
import java.util.HashSet;
53
import java.util.Set;
64

5+
import com.google.common.collect.Sets;
6+
77
public class TreeNode {
88

99
int value;
@@ -12,8 +12,7 @@ public class TreeNode {
1212

1313
public TreeNode(int value, TreeNode... children) {
1414
this.value = value;
15-
this.children = new HashSet<>();
16-
this.children.addAll(Arrays.asList(children));
15+
this.children = Sets.newHashSet(children);
1716
}
1817

1918
}

0 commit comments

Comments
 (0)