Skip to content

Commit 2a1fc6b

Browse files
committed
Simplify array cloning.
1 parent 00ea5ee commit 2a1fc6b

4 files changed

Lines changed: 4 additions & 8 deletions

File tree

src/main/java/org/apache/commons/codec/binary/Base32.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,7 @@ public Base32(final int lineLength, final byte[] lineSeparator, final boolean us
334334
throw new IllegalArgumentException("lineSeparator must not contain Base32 characters: [" + sep + "]");
335335
}
336336
this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length;
337-
this.lineSeparator = new byte[lineSeparator.length];
338-
System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length);
337+
this.lineSeparator = lineSeparator.clone();
339338
} else {
340339
this.encodeSize = BYTES_PER_ENCODED_BLOCK;
341340
this.lineSeparator = null;

src/main/java/org/apache/commons/codec/binary/Base64.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,7 @@ public Base64(final int lineLength, final byte[] lineSeparator, final boolean ur
596596
}
597597
if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE
598598
this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length;
599-
this.lineSeparator = new byte[lineSeparator.length];
600-
System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length);
599+
this.lineSeparator = lineSeparator.clone();
601600
} else {
602601
this.encodeSize = BYTES_PER_ENCODED_BLOCK;
603602
this.lineSeparator = null;

src/main/java/org/apache/commons/codec/language/RefinedSoundex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,7 @@ public RefinedSoundex() {
8787
* a given character
8888
*/
8989
public RefinedSoundex(final char[] mapping) {
90-
this.soundexMapping = new char[mapping.length];
91-
System.arraycopy(mapping, 0, this.soundexMapping, 0, mapping.length);
90+
this.soundexMapping = mapping.clone();
9291
}
9392

9493
/**

src/main/java/org/apache/commons/codec/language/Soundex.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ public Soundex() {
150150
* Mapping array to use when finding the corresponding code for a given character
151151
*/
152152
public Soundex(final char[] mapping) {
153-
this.soundexMapping = new char[mapping.length];
154-
System.arraycopy(mapping, 0, this.soundexMapping, 0, mapping.length);
153+
this.soundexMapping = mapping.clone();
155154
this.specialCaseHW = !hasMarker(this.soundexMapping);
156155
}
157156

0 commit comments

Comments
 (0)