mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2025-10-16 11:45:37 +00:00
Avoid copying from Array to list and back
As Java's Lists use boxed Integers, we try to avoid the memory consumption, GC pressure and time overhead caused by copying an int[] into a List<Integer> and back again.
This commit is contained in:
parent
53df67d490
commit
c4535aefbe
@ -54,29 +54,16 @@ public class Signing {
|
||||
curl.reset();
|
||||
curl.absorb(seed, 0, seed.length);
|
||||
|
||||
final List<Integer> key = new ArrayList<>();
|
||||
int[] buffer = new int[seed.length];
|
||||
final int[] key = new int[length * seed.length * 27];
|
||||
int offset = 0;
|
||||
|
||||
while (length-- > 0) {
|
||||
|
||||
for (int i = 0; i < 27; i++) {
|
||||
curl.squeeze(buffer, offset, buffer.length);
|
||||
for (int j = 0; j < 243; j++) {
|
||||
key.add(buffer[j]);
|
||||
}
|
||||
curl.squeeze(key, offset, seed.length);
|
||||
offset += seed.length;
|
||||
}
|
||||
}
|
||||
return to(key);
|
||||
}
|
||||
|
||||
private int[] to(List<Integer> key) {
|
||||
int a[] = new int[key.size()];
|
||||
int i = 0;
|
||||
for (Integer v : key) {
|
||||
a[i++] = v;
|
||||
}
|
||||
return a;
|
||||
return key;
|
||||
}
|
||||
|
||||
public int[] signatureFragment(int[] normalizedBundleFragment, int[] keyFragment) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user