From f2f2b487827db06933c793204cdf55f34ad0890c Mon Sep 17 00:00:00 2001 From: Sergey Petunin Date: Tue, 9 Aug 2016 18:56:35 +0600 Subject: [PATCH] Optimized the TreeNode constructor (#590) --- .../src/main/java/com/baeldung/threadpool/TreeNode.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/core-java-8/src/main/java/com/baeldung/threadpool/TreeNode.java b/core-java-8/src/main/java/com/baeldung/threadpool/TreeNode.java index 72b1f756a8..9b43152074 100644 --- a/core-java-8/src/main/java/com/baeldung/threadpool/TreeNode.java +++ b/core-java-8/src/main/java/com/baeldung/threadpool/TreeNode.java @@ -1,9 +1,9 @@ package com.baeldung.threadpool; -import java.util.Arrays; -import java.util.HashSet; import java.util.Set; +import com.google.common.collect.Sets; + public class TreeNode { int value; @@ -12,8 +12,7 @@ public class TreeNode { public TreeNode(int value, TreeNode... children) { this.value = value; - this.children = new HashSet<>(); - this.children.addAll(Arrays.asList(children)); + this.children = Sets.newHashSet(children); } }