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;
}
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) {
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) {
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()) {
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);
}
return frames.toArray(new String[0]);
return frames.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
/**
@ -325,7 +325,7 @@ public class ExceptionUtils {
while (frames.hasMoreTokens()) {
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) {
// still call tokenize as subclass may do some work
final List<String> split = tokenize(null, 0, 0);
tokens = split.toArray(new String[0]);
tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
} else {
final List<String> split = tokenize(chars, 0, chars.length);
tokens = split.toArray(new String[0]);
tokens = split.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
}
}
}