From 7868c0e83a716824025eb6758d5725ca86144267 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Thu, 20 Apr 2017 12:32:55 +0300 Subject: [PATCH] avoid string concat in a loop --- .../code/cfg/ExceptionRangeCFG.java | 21 +++---------------- 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/code/cfg/ExceptionRangeCFG.java b/src/org/jetbrains/java/decompiler/code/cfg/ExceptionRangeCFG.java index 38a105b..84640d7 100644 --- a/src/org/jetbrains/java/decompiler/code/cfg/ExceptionRangeCFG.java +++ b/src/org/jetbrains/java/decompiler/code/cfg/ExceptionRangeCFG.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2014 JetBrains s.r.o. + * Copyright 2000-2017 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,8 @@ package org.jetbrains.java.decompiler.code.cfg; import org.jetbrains.java.decompiler.main.DecompilerContext; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; -import java.util.Set; +import java.util.stream.Collectors; public class ExceptionRangeCFG { @@ -105,21 +104,7 @@ public class ExceptionRangeCFG { return null; } - Set setExceptionStrings = new HashSet<>(); - - for (String exceptionType : exceptionTypes) { // normalize order - setExceptionStrings.add(exceptionType); - } - - String ret = ""; - for (String exception : setExceptionStrings) { - if (!ret.isEmpty()) { - ret += ":"; - } - ret += exception; - } - - return ret; + return exceptionTypes.stream().distinct().collect(Collectors.joining(":")); }