Skip to content

Commit 5af372c

Browse files
committed
Simplify copy logic in Base64
1 parent 8bd92c8 commit 5af372c

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/main/java/at/favre/lib/bytes/Base64.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121

2222
package at.favre.lib.bytes;
2323

24+
import java.util.Arrays;
25+
2426
/**
2527
* From https://github.com/square/okio/blob/okio-parent-1.15.0/okio/src/main/java/okio/Base64.java
2628
* under Apache 2 license.
@@ -121,9 +123,7 @@ static byte[] decode(String in) {
121123
if (outCount == out.length) return out;
122124

123125
// Copy the decoded bytes to a new, right-sized array.
124-
byte[] prefix = new byte[outCount];
125-
System.arraycopy(out, 0, prefix, 0, outCount);
126-
return prefix;
126+
return Arrays.copyOfRange(out, 0, outCount);
127127
}
128128

129129
static byte[] encode(byte[] in) {

0 commit comments

Comments
 (0)