avoid string concat in a loop

master
Egor.Ushakov 8 years ago
parent 0a7a60fa7b
commit 7868c0e83a
  1. 21
      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<String> 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(":"));
}

Loading…
Cancel
Save