[Java] Avoid unnecessary array copying in tests (#247)

This commit is contained in:
Stefan Bratanov 2023-03-24 15:53:46 +00:00 committed by GitHub
parent 7695db3330
commit 88924c8aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 5 additions and 10 deletions

View File

@ -6,7 +6,6 @@ import ethereum.ckzg4844.test_formats.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.math.BigInteger;
import java.nio.ByteBuffer;
@ -234,10 +233,6 @@ public class TestUtils {
return randomBLSFieldElement().toArray(ByteOrder.LITTLE_ENDIAN);
}
private static InputStream readResource(final String resource) {
return Thread.currentThread().getContextClassLoader().getResourceAsStream(resource);
}
public static List<String> getFiles(String path) {
try {
try (Stream<Path> stream = Files.list(Paths.get(path))) {

View File

@ -7,7 +7,7 @@ public class BlobToKzgCommitmentTest {
private String blob;
public byte[] getBlob() {
return Bytes.fromHexString(blob).toArray();
return Bytes.fromHexString(blob).toArrayUnsafe();
}
}

View File

@ -8,7 +8,7 @@ public class ComputeBlobKzgProofTest {
private String commitment;
public byte[] getBlob() {
return Bytes.fromHexString(blob).toArray();
return Bytes.fromHexString(blob).toArrayUnsafe();
}
public byte[] getCommitment() {

View File

@ -10,7 +10,7 @@ public class ComputeKzgProofTest {
private String z;
public byte[] getBlob() {
return Bytes.fromHexString(blob).toArray();
return Bytes.fromHexString(blob).toArrayUnsafe();
}
public byte[] getZ() {

View File

@ -15,7 +15,7 @@ public class VerifyBlobKzgProofBatchTest {
return TestUtils.flatten(
blobs.stream()
.map(Bytes::fromHexString)
.map(Bytes::toArray)
.map(Bytes::toArrayUnsafe)
.collect(Collectors.toList())
.toArray(byte[][]::new));
}

View File

@ -9,7 +9,7 @@ public class VerifyBlobKzgProofTest {
private String proof;
public byte[] getBlob() {
return Bytes.fromHexString(blob).toArray();
return Bytes.fromHexString(blob).toArrayUnsafe();
}
public byte[] getCommitment() {