mirror of
https://github.com/gosticks/iota.lib.java.git
synced 2026-10-04 13:37:00 +00:00
Use correct arraycopy length
The code copies 243 single adjacent element in an array using arraycopy in a loop. For copying single elements, direct array access is more performant (as it avoids the penalty of calling into native code and the JIT may detect patterns and optimize them). However, in this case, as the copied elements are adjacent, replace the whole loop with a single arraycopy call.
This commit is contained in:
@@ -93,9 +93,7 @@ public class Signing {
|
||||
.squeeze(hash, 0, hash.length);
|
||||
}
|
||||
|
||||
for (int j = 0; j < 243; j++) {
|
||||
System.arraycopy(hash, j, keyFragment, i * 243 + j, 1);
|
||||
}
|
||||
System.arraycopy(hash, 0, keyFragment, i * 243, 243);
|
||||
}
|
||||
|
||||
return keyFragment;
|
||||
@@ -202,9 +200,7 @@ public class Signing {
|
||||
|
||||
int[] digestBuffer = digest(normalizedBundleFragments[i % 3], Converter.trits(signatureFragments[i]));
|
||||
|
||||
for (int j = 0; j < 243; j++) {
|
||||
System.arraycopy(digestBuffer, j, digests, i * 243 + j, 1);
|
||||
}
|
||||
System.arraycopy(digestBuffer, 0, digests, i * 243, 243);
|
||||
}
|
||||
String address = Converter.trytes(address(digests));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user