Skip to content

Commit 9580482

Browse files
committed
Replace manual array copy with System.arraycopy()
This approach is more efficient.
1 parent 2bba5dd commit 9580482

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

src/main/java/com/fasterxml/jackson/core/io/UTF32Reader.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,7 @@ private boolean loadMore(int available) throws IOException {
201201
// Bytes that need to be moved to the beginning of buffer?
202202
if (available > 0) {
203203
if (_ptr > 0) {
204-
for (int i = 0; i < available; ++i) {
205-
_buffer[i] = _buffer[_ptr+i];
206-
}
204+
System.arraycopy(_buffer, _ptr, _buffer, 0, available);
207205
_ptr = 0;
208206
}
209207
_length = available;

src/main/java/com/fasterxml/jackson/core/sym/BytesToNameCanonicalizer.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,9 +1049,7 @@ private static Name constructName(int hash, String name, int[] quads, int qlen)
10491049
}
10501050
// Otherwise, need to copy the incoming buffer
10511051
int[] buf = new int[qlen];
1052-
for (int i = 0; i < qlen; ++i) {
1053-
buf[i] = quads[i];
1054-
}
1052+
System.arraycopy(quads, 0, buf, 0, qlen);
10551053
return new NameN(name, hash, buf, qlen);
10561054
}
10571055

0 commit comments

Comments
 (0)