From d24022d755cac1b2a6e9f6c5ec11c1d1bb4387cd Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sat, 24 Jun 2017 16:13:55 +0200 Subject: [PATCH] cleanup nameWithoutVersion() code --- .../conversations/entities/Presences.java | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/entities/Presences.java b/src/main/java/eu/siacs/conversations/entities/Presences.java index 57a8e5fe1..c8301123b 100644 --- a/src/main/java/eu/siacs/conversations/entities/Presences.java +++ b/src/main/java/eu/siacs/conversations/entities/Presences.java @@ -130,21 +130,17 @@ public class Presences { private static String nameWithoutVersion(String name) { String[] parts = name.split(" "); - if (parts.length <= 1) { - return name; - } else { - if (Character.isDigit(parts[parts.length -1].charAt(0))) { - StringBuilder output = new StringBuilder(); - for(int i = 0; i < parts.length -1; ++i) { - if (output.length() != 0) { - output.append(' '); - } - output.append(parts[i]); + if (parts.length > 1 && Character.isDigit(parts[parts.length -1].charAt(0))) { + StringBuilder output = new StringBuilder(); + for(int i = 0; i < parts.length -1; ++i) { + if (output.length() != 0) { + output.append(' '); } - return output.toString(); - } else { - return name; + output.append(parts[i]); } + return output.toString(); + } else { + return name; } } }