Skip to content

Commit 8ec68f4

Browse files
committed
Rename internal methods and field
These are not just for "skipping"
1 parent 8814b6d commit 8ec68f4

2 files changed

Lines changed: 14 additions & 14 deletions

File tree

src/main/java/org/apache/commons/io/CopyUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public static int copy(
266266
final Reader input,
267267
final Writer output)
268268
throws IOException {
269-
final char[] buffer = IOUtils.getCharArray();
269+
final char[] buffer = IOUtils.getScratchCharArray();
270270
int count = 0;
271271
int n;
272272
while (EOF != (n = input.read(buffer))) {

src/main/java/org/apache/commons/io/IOUtils.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,12 @@ public class IOUtils {
195195
/**
196196
* Internal byte array buffer.
197197
*/
198-
private static final ThreadLocal<byte[]> SKIP_BYTE_BUFFER = ThreadLocal.withInitial(IOUtils::byteArray);
198+
private static final ThreadLocal<byte[]> SCRATCH_BYTE_BUFFER = ThreadLocal.withInitial(IOUtils::byteArray);
199199

200200
/**
201201
* Internal byte array buffer.
202202
*/
203-
private static final ThreadLocal<char[]> SKIP_CHAR_BUFFER = ThreadLocal.withInitial(IOUtils::charArray);
203+
private static final ThreadLocal<char[]> SCRATCH_CHAR_BUFFER = ThreadLocal.withInitial(IOUtils::charArray);
204204

205205
/**
206206
* Returns the given InputStream if it is already a {@link BufferedInputStream}, otherwise creates a
@@ -879,7 +879,7 @@ public static boolean contentEquals(final InputStream input1, final InputStream
879879
}
880880

881881
// reuse one
882-
final byte[] array1 = getByteArray();
882+
final byte[] array1 = getScratchByteArray();
883883
// allocate another
884884
final byte[] array2 = byteArray();
885885
int pos1;
@@ -950,7 +950,7 @@ public static boolean contentEquals(final Reader input1, final Reader input2) th
950950
}
951951

952952
// reuse one
953-
final char[] array1 = getCharArray();
953+
final char[] array1 = getScratchCharArray();
954954
// but allocate another
955955
final char[] array2 = charArray();
956956
int pos1;
@@ -1489,7 +1489,7 @@ public static long copyLarge(final InputStream inputStream, final OutputStream o
14891489
*/
14901490
public static long copyLarge(final InputStream input, final OutputStream output, final long inputOffset,
14911491
final long length) throws IOException {
1492-
return copyLarge(input, output, inputOffset, length, getByteArray());
1492+
return copyLarge(input, output, inputOffset, length, getScratchByteArray());
14931493
}
14941494

14951495
/**
@@ -1560,7 +1560,7 @@ public static long copyLarge(final InputStream input, final OutputStream output,
15601560
* @since 1.3
15611561
*/
15621562
public static long copyLarge(final Reader reader, final Writer writer) throws IOException {
1563-
return copyLarge(reader, writer, getCharArray());
1563+
return copyLarge(reader, writer, getScratchCharArray());
15641564
}
15651565

15661566
/**
@@ -1611,7 +1611,7 @@ public static long copyLarge(final Reader reader, final Writer writer, final cha
16111611
*/
16121612
public static long copyLarge(final Reader reader, final Writer writer, final long inputOffset, final long length)
16131613
throws IOException {
1614-
return copyLarge(reader, writer, inputOffset, length, getCharArray());
1614+
return copyLarge(reader, writer, inputOffset, length, getScratchCharArray());
16151615
}
16161616

16171617
/**
@@ -1664,17 +1664,17 @@ public static long copyLarge(final Reader reader, final Writer writer, final lon
16641664
*
16651665
* @return the thread local byte array.
16661666
*/
1667-
static byte[] getByteArray() {
1668-
return SKIP_BYTE_BUFFER.get();
1667+
static byte[] getScratchByteArray() {
1668+
return SCRATCH_BYTE_BUFFER.get();
16691669
}
16701670

16711671
/**
16721672
* Gets the thread local char array.
16731673
*
16741674
* @return the thread local char array.
16751675
*/
1676-
static char[] getCharArray() {
1677-
return SKIP_CHAR_BUFFER.get();
1676+
static char[] getScratchCharArray() {
1677+
return SCRATCH_CHAR_BUFFER.get();
16781678
}
16791679

16801680
/**
@@ -2300,7 +2300,7 @@ public static long skip(final InputStream input, final long toSkip) throws IOExc
23002300
long remain = toSkip;
23012301
while (remain > 0) {
23022302
// See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip()
2303-
final byte[] byteArray = getByteArray();
2303+
final byte[] byteArray = getScratchByteArray();
23042304
final long n = input.read(byteArray, 0, (int) Math.min(remain, byteArray.length));
23052305
if (n < 0) { // EOF
23062306
break;
@@ -2368,7 +2368,7 @@ public static long skip(final Reader reader, final long toSkip) throws IOExcepti
23682368
long remain = toSkip;
23692369
while (remain > 0) {
23702370
// See https://issues.apache.org/jira/browse/IO-203 for why we use read() rather than delegating to skip()
2371-
final char[] charArray = getCharArray();
2371+
final char[] charArray = getScratchCharArray();
23722372
final long n = reader.read(charArray, 0, (int) Math.min(remain, charArray.length));
23732373
if (n < 0) { // EOF
23742374
break;

0 commit comments

Comments
 (0)