Replace some manual array copies with System.arraycopy
This commit is contained in:
parent
fbff5e7dd6
commit
487b09fccc
|
@ -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");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue