Explorar el Código

Determine the size of the array

Avoid expansion or memory waste
dwq hace 4 años
padre
commit
d4747df3fd
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  1. 1 1
      examples/src/main/java/MilvusClientExample.java

+ 1 - 1
examples/src/main/java/MilvusClientExample.java

@@ -36,7 +36,7 @@ public class MilvusClientExample {
   // Helper function that generates random vectors
   static List<List<Float>> generateVectors(long vectorCount, long dimension) {
     SplittableRandom splitcollectionRandom = new SplittableRandom();
-    List<List<Float>> vectors = new ArrayList<>();
+    List<List<Float>> vectors = new ArrayList<>(vectorCount);
     for (long i = 0; i < vectorCount; ++i) {
       splitcollectionRandom = splitcollectionRandom.split();
       DoubleStream doubleStream = splitcollectionRandom.doubles(dimension);