Simplify StringUtils#commonPrefix

By first checking for null-ness and then for the number of strings to
compare we can get rid of a redundant null check.

Change-Id: I0d9a088352c6c1ffea12bc2cded2c63e5293a8a7
This commit is contained in:
Nasser Grainawi 2023-11-14 00:12:24 +01:00 committed by Matthias Sohn
parent 4f18c50950
commit 4aaf8cad90
1 changed files with 3 additions and 3 deletions

View File

@ -480,13 +480,13 @@ public static String formatWithSuffix(long value) {
if (strings == null || strings.length == 0) {
return EMPTY;
}
if (strings.length == 1) {
return strings[0] == null ? EMPTY : strings[0];
}
String first = strings[0];
if (first == null) {
return EMPTY;
}
if (strings.length == 1) {
return first;
}
for (int i = 0; i < first.length(); i++) {
char currentChar = first.charAt(i);
for (int j = 1; j < strings.length; j++) {