avoid using Arrays.asList for a single element

master
Egor.Ushakov 10 years ago
parent e54dc7d531
commit 768f82b798
  1. 4
      src/org/jetbrains/java/decompiler/code/cfg/ControlFlowGraph.java
  2. 5
      src/org/jetbrains/java/decompiler/main/AssertProcessor.java
  3. 2
      src/org/jetbrains/java/decompiler/modules/decompiler/ExprProcessor.java
  4. 12
      src/org/jetbrains/java/decompiler/modules/decompiler/IfHelper.java
  5. 5
      src/org/jetbrains/java/decompiler/modules/decompiler/PPandMMHelper.java
  6. 7
      src/org/jetbrains/java/decompiler/modules/decompiler/SecondaryFunctionsHelper.java
  7. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/SimplifyExprentsHelper.java
  8. 6
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/FunctionExprent.java
  9. 4
      src/org/jetbrains/java/decompiler/modules/decompiler/exps/IfExprent.java

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -397,7 +397,7 @@ public class ControlFlowGraph implements CodeConstants {
ExceptionRangeCFG range = new ExceptionRangeCFG(protectedRange, handle, handler.exceptionClass == null
? null
: Arrays.asList(handler.exceptionClass));
: Collections.singletonList(handler.exceptionClass));
mapRanges.put(key, range);
exceptions.add(range);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -173,8 +173,7 @@ public class AssertProcessor {
Exprent ascond = null, retcond = null;
if (exprres[0] != null) {
ascond = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT,
Arrays.asList((Exprent)exprres[0]), throwError.bytecode);
ascond = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, (Exprent)exprres[0], throwError.bytecode);
retcond = SecondaryFunctionsHelper.propagateBoolNot(ascond);
}

@ -336,7 +336,7 @@ public class ExprProcessor implements CodeConstants {
Instruction instr = seq.getInstr(i);
Integer bytecode_offset = block.getOldOffset(i);
Set<Integer> bytecode_offsets = bytecode_offset >= 0 ? new HashSet<Integer>(Arrays.asList(bytecode_offset)) : null;
Set<Integer> bytecode_offsets = bytecode_offset >= 0 ? Collections.singleton(bytecode_offset) : null;
switch (instr.opcode) {
case opc_aconst_null:

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -252,8 +252,7 @@ public class IfHelper {
List<Exprent> lstOperands = new ArrayList<Exprent>();
lstOperands.add(statexpr.getCondition());
lstOperands.add(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT,
Arrays.asList(ifchild.getHeadexprent().getCondition()), null));
lstOperands.add(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, ifchild.getHeadexprent().getCondition(), null));
statexpr.setCondition(new FunctionExprent(FunctionExprent.FUNCTION_CADD, lstOperands, null));
statexpr.addBytecodeOffsets(ifchild.getHeadexprent().bytecode);
@ -310,8 +309,7 @@ public class IfHelper {
lstOperands.add(firstif.getHeadexprent().getCondition());
if (path == 2) {
lstOperands.set(0, new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT,
Arrays.asList(lstOperands.get(0)), null));
lstOperands.set(0, new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, lstOperands.get(0), null));
}
lstOperands.add(statexpr.getCondition());
@ -361,7 +359,7 @@ public class IfHelper {
// negate the if condition
IfExprent statexpr = firstif.getHeadexprent();
statexpr
.setCondition(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, Arrays.asList(statexpr.getCondition()), null));
.setCondition(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, statexpr.getCondition(), null));
return true;
}
@ -556,7 +554,7 @@ public class IfHelper {
// negate the if condition
IfExprent statexpr = ifstat.getHeadexprent();
statexpr.setCondition(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, Arrays.asList(statexpr.getCondition()), null));
statexpr.setCondition(new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, statexpr.getCondition(), null));
if (noelsestat) {
StatEdge ifedge = ifstat.getIfEdge();

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -25,7 +25,6 @@ import org.jetbrains.java.decompiler.modules.decompiler.sforms.FlattenStatements
import org.jetbrains.java.decompiler.modules.decompiler.stats.RootStatement;
import org.jetbrains.java.decompiler.struct.gen.VarType;
import java.util.Arrays;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
@ -138,7 +137,7 @@ public class PPandMMHelper {
if (left.equals(econd) && (midlayer == null || midlayer.equals(condtype))) {
FunctionExprent ret = new FunctionExprent(
func.getFuncType() == FunctionExprent.FUNCTION_ADD ? FunctionExprent.FUNCTION_PPI : FunctionExprent.FUNCTION_MMI,
Arrays.asList(econd), func.bytecode);
econd, func.bytecode);
ret.setImplicitType(condtype);
exprentReplaced = true;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -286,7 +286,7 @@ public class SecondaryFunctionsHelper {
cexpr2.getExprType().type == CodeConstants.TYPE_BOOLEAN) {
if (cexpr1.getIntValue() == 0 && cexpr2.getIntValue() != 0) {
return new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, Arrays.asList(lstOperands.get(0)), fexpr.bytecode);
return new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, lstOperands.get(0), fexpr.bytecode);
}
else if (cexpr1.getIntValue() != 0 && cexpr2.getIntValue() == 0) {
return lstOperands.get(0);
@ -407,8 +407,7 @@ public class SecondaryFunctionsHelper {
case FunctionExprent.FUNCTION_COR:
List<Exprent> operands = fparam.getLstOperands();
for (int i = 0; i < operands.size(); i++) {
Exprent newparam = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT,
Arrays.asList(operands.get(i)), operands.get(i).bytecode);
Exprent newparam = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, operands.get(i), operands.get(i).bytecode);
Exprent retparam = propagateBoolNot(newparam);
operands.set(i, retparam == null ? newparam : retparam);

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -448,7 +448,7 @@ public class SimplifyExprentsHelper {
if (left.type != Exprent.EXPRENT_VAR && left.equals(econd)) {
FunctionExprent ret = new FunctionExprent(
func.getFuncType() == FunctionExprent.FUNCTION_ADD ? FunctionExprent.FUNCTION_PPI : FunctionExprent.FUNCTION_MMI,
Arrays.asList(econd), func.bytecode);
econd, func.bytecode);
ret.setImplicitType(VarType.VARTYPE_INT);
return ret;
}

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -220,6 +220,10 @@ public class FunctionExprent extends Exprent {
addBytecodeOffsets(bytecodeOffsets);
}
public FunctionExprent(int funcType, Exprent operand, Set<Integer> bytecodeOffsets) {
this(funcType, Collections.singletonList(operand), bytecodeOffsets);
}
@Override
public VarType getExprType() {
VarType exprType = null;

@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 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.
@ -135,7 +135,7 @@ public class IfExprent extends Exprent {
}
public IfExprent negateIf() {
condition = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, Collections.singletonList(condition), condition.bytecode);
condition = new FunctionExprent(FunctionExprent.FUNCTION_BOOL_NOT, condition, condition.bytecode);
return this;
}

Loading…
Cancel
Save