Replace some manual array copies with System.arraycopy

This commit is contained in:
Ville Skyttä 2016-04-10 12:34:56 +03:00 committed by Clebert Suconic
parent fbff5e7dd6
commit 487b09fccc
5 changed files with 7 additions and 21 deletions

View File

@ -56,9 +56,7 @@ public class DefaultSensitiveStringCodec implements SensitiveDataCodec<String> {
int pad = newLength - length; // number of leading zeros
byte[] old = encoding;
encoding = new byte[newLength];
for (int i = old.length - 1; i >= 0; i--) {
encoding[i + pad] = old[i];
}
System.arraycopy(old, 0, encoding, pad, old.length);
}
Cipher cipher = Cipher.getInstance("Blowfish");

View File

@ -96,9 +96,7 @@ public final class UUIDGenerator {
public UUID generateTimeBasedUUID(final byte[] byteAddr) {
byte[] contents = new byte[16];
int pos = 10;
for (int i = 0; i < 6; ++i) {
contents[pos + i] = byteAddr[i];
}
System.arraycopy(byteAddr, 0, contents, pos, 6);
synchronized (mTimerLock) {
if (mTimer == null) {

View File

@ -144,9 +144,7 @@ public final class ReplicationEndpoint implements ChannelHandler, ActiveMQCompon
journals = new Journal[id + 1];
if (oldJournals != null) {
for (int i = 0; i < oldJournals.length; i++) {
journals[i] = oldJournals[i];
}
System.arraycopy(oldJournals, 0, journals, 0, oldJournals.length);
}
}

View File

@ -166,9 +166,7 @@ public class SimpleJMSMapMessage extends SimpleJMSMessage implements MapMessage
throw new JMSException("Array is too small");
}
byte[] temp = new byte[length];
for (int i = 0; i < length; i++) {
temp[i] = value[i + offset];
}
System.arraycopy(value, offset, temp, 0, length);
content.put(name, temp);

View File

@ -409,9 +409,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe
}
if (obj.length - offset < value.length) {
for (int i = 0; i < obj.length; i++) {
value[i] = obj[i + offset];
}
System.arraycopy(obj, offset, value, 0, obj.length);
position++;
offset = 0;
@ -419,9 +417,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe
return obj.length - offset;
}
else {
for (int i = 0; i < value.length; i++) {
value[i] = obj[i + offset];
}
System.arraycopy(obj, offset, value, 0, value.length);
offset += value.length;
return value.length;
@ -545,9 +541,7 @@ public class SimpleJMSStreamMessage extends SimpleJMSMessage implements StreamMe
throw new JMSException("Array is too small");
}
byte[] temp = new byte[length];
for (int i = 0; i < length; i++) {
temp[i] = value[i + offset];
}
System.arraycopy(value, offset, temp, 0, length);
content.add(temp);
}