Use ArrayUtils#EMPTY_STRING_ARRAY instead of creating new empty String arrays.

This commit is contained in:
pascalschumacher 2019-12-26 23:51:46 +01:00
parent 84668a2d98
commit d5948be13f
3 changed files with 9 additions and 9 deletions

View File

@ -7507,7 +7507,7 @@ public class StringUtils {
currentType = type; currentType = type;
} }
list.add(new String(c, tokenStart, c.length - tokenStart)); list.add(new String(c, tokenStart, c.length - tokenStart));
return list.toArray(new String[0]); return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**
@ -7735,7 +7735,7 @@ public class StringUtils {
} }
} }
return substrings.toArray(new String[0]); return substrings.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -7923,7 +7923,7 @@ public class StringUtils {
if (match || preserveAllTokens && lastMatch) { if (match || preserveAllTokens && lastMatch) {
list.add(str.substring(start, i)); list.add(str.substring(start, i));
} }
return list.toArray(new String[0]); return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**
@ -8022,7 +8022,7 @@ public class StringUtils {
if (match || preserveAllTokens && lastMatch) { if (match || preserveAllTokens && lastMatch) {
list.add(str.substring(start, i)); list.add(str.substring(start, i));
} }
return list.toArray(new String[0]); return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**
@ -8835,7 +8835,7 @@ public class StringUtils {
if (list.isEmpty()) { if (list.isEmpty()) {
return null; return null;
} }
return list.toArray(new String[0]); return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**

View File

@ -274,7 +274,7 @@ public class ExceptionUtils {
} }
frames.addAll(trace); frames.addAll(trace);
} }
return frames.toArray(new String[0]); return frames.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**
@ -325,7 +325,7 @@ public class ExceptionUtils {
while (frames.hasMoreTokens()) { while (frames.hasMoreTokens()) {
list.add(frames.nextToken()); list.add(frames.nextToken());
} }
return list.toArray(new String[0]); return list.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
/** /**

View File

@ -604,10 +604,10 @@ public class StrTokenizer implements ListIterator<String>, Cloneable {
if (chars == null) { if (chars == null) {
// still call tokenize as subclass may do some work // still call tokenize as subclass may do some work
final List<String> split = tokenize(null, 0, 0); final List<String> split = tokenize(null, 0, 0);
tokens = split.toArray(new String[0]); tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} else { } else {
final List<String> split = tokenize(chars, 0, chars.length); final List<String> split = tokenize(chars, 0, chars.length);
tokens = split.toArray(new String[0]); tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} }
} }
} }