summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit
diff options
context:
space:
mode:
authorNasser Grainawi <quic_nasserg@quicinc.com>2023-11-14 00:12:24 +0100
committerMatthias Sohn <matthias.sohn@sap.com>2023-11-14 09:13:19 +0100
commit4aaf8cad90ad94d96cf93f6163562b496a3bef7a (patch)
treec2d694686f801e1dbad5bd82224152b121cb86b3 /org.eclipse.jgit
parent4f18c5095049116350828e9bb499964ea887ac02 (diff)
downloadjgit-4aaf8cad90ad94d96cf93f6163562b496a3bef7a.tar.gz
jgit-4aaf8cad90ad94d96cf93f6163562b496a3bef7a.zip
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
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r--org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java6
1 files changed, 3 insertions, 3 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
index e1567c1864..2fbd12dcc5 100644
--- a/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
+++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/StringUtils.java
@@ -480,13 +480,13 @@ public final class StringUtils {
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++) {