Skip to content

Commit 80aee43

Browse files
johnmayegonw
authored andcommitted
Avoid Longs.toArray and just create the array
1 parent b62c970 commit 80aee43

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

base/test-standard/src/test/java/org/openscience/cdk/graph/invariant/InvariantRankerTest.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,9 @@
2424

2525
package org.openscience.cdk.graph.invariant;
2626

27-
import com.google.common.primitives.Longs;
2827
import org.junit.Test;
2928

30-
import java.util.HashSet;
3129
import java.util.Random;
32-
import java.util.Set;
3330

3431
import static org.hamcrest.CoreMatchers.is;
3532
import static org.hamcrest.MatcherAssert.assertThat;
@@ -115,11 +112,9 @@ public void mergeSort() {
115112

116113
// random (unique) values in random order
117114
Random rnd = new Random();
118-
Set<Long> values = new HashSet<Long>();
119-
while (values.size() < n)
120-
values.add(rnd.nextLong());
121-
122-
long[] prev = Longs.toArray(values);
115+
long[] prev = new long[n];
116+
for (int i=0; i<n; i++)
117+
prev[i] = rnd.nextLong();
123118

124119
// ident array
125120
int[] vs = new int[n];
@@ -141,11 +136,9 @@ public void mergeSort_range() {
141136

142137
// random (unique) values in random order
143138
Random rnd = new Random();
144-
Set<Long> values = new HashSet<Long>();
145-
while (values.size() < n)
146-
values.add(rnd.nextLong());
147-
148-
long[] prev = Longs.toArray(values);
139+
long[] prev = new long[n];
140+
for (int i=0; i<n; i++)
141+
prev[i] = rnd.nextLong();
149142

150143
// ident array
151144
int[] vs = new int[n];

0 commit comments

Comments
 (0)