From 8824c20cbb0fd2320ac9a11a0c93469c43d78a24 Mon Sep 17 00:00:00 2001 From: stsypanov Date: Wed, 25 Jul 2018 14:57:45 +0200 Subject: [PATCH] improve performance of logical conjunction (IDEA-182226) --- .../java/decompiler/modules/code/DeadCodeHelper.java | 4 ++-- .../java/decompiler/modules/decompiler/DecHelper.java | 7 +++++-- .../decompiler/modules/decompiler/FinallyProcessor.java | 7 +++++-- .../modules/decompiler/stats/CatchAllStatement.java | 9 ++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/org/jetbrains/java/decompiler/modules/code/DeadCodeHelper.java b/src/org/jetbrains/java/decompiler/modules/code/DeadCodeHelper.java index 6f50c61..143dbca 100644 --- a/src/org/jetbrains/java/decompiler/modules/code/DeadCodeHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/code/DeadCodeHelper.java @@ -216,14 +216,14 @@ public class DeadCodeHelper { for (int i = 0; i < node.getPreds().size(); i++) { BasicBlock pred = node.getPreds().get(i); - if (!marked.contains(pred) && pred != dom) { + if (pred != dom && !marked.contains(pred)) { lstNodes.add(pred); } } for (int i = 0; i < node.getPredExceptions().size(); i++) { BasicBlock pred = node.getPredExceptions().get(i); - if (!marked.contains(pred) && pred != dom) { + if (pred != dom && !marked.contains(pred)) { lstNodes.add(pred); } } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/DecHelper.java b/src/org/jetbrains/java/decompiler/modules/decompiler/DecHelper.java index 50b76a7..8cfcdf7 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/DecHelper.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/DecHelper.java @@ -4,7 +4,10 @@ package org.jetbrains.java.decompiler.modules.decompiler; import org.jetbrains.java.decompiler.modules.decompiler.exps.Exprent; import org.jetbrains.java.decompiler.modules.decompiler.stats.Statement; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; public class DecHelper { @@ -145,7 +148,7 @@ public class DecHelper { if (head == statd) { return false; } - if (!setDest.contains(statd) && post != statd) { + if (post != statd && !setDest.contains(statd)) { if (post != null) { return false; } diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java index 3e213da..d087783 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/FinallyProcessor.java @@ -1,7 +1,10 @@ // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package org.jetbrains.java.decompiler.modules.decompiler; -import org.jetbrains.java.decompiler.code.*; +import org.jetbrains.java.decompiler.code.CodeConstants; +import org.jetbrains.java.decompiler.code.Instruction; +import org.jetbrains.java.decompiler.code.InstructionSequence; +import org.jetbrains.java.decompiler.code.SimpleInstructionSequence; import org.jetbrains.java.decompiler.code.cfg.BasicBlock; import org.jetbrains.java.decompiler.code.cfg.ControlFlowGraph; import org.jetbrains.java.decompiler.code.cfg.ExceptionRangeCFG; @@ -321,7 +324,7 @@ public class FinallyProcessor { for (BasicBlock dest : lstSucc) { // break out - if (!setCopy.contains(dest) && dest != graph.getLast()) { + if (dest != graph.getLast() && !setCopy.contains(dest)) { // disable semaphore SimpleInstructionSequence seq = new SimpleInstructionSequence(); seq.addInstruction(Instruction.create(CodeConstants.opc_bipush, false, CodeConstants.GROUP_GENERAL, bytecode_version, new int[]{0}), -1); diff --git a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java index 8d50513..6467acd 100644 --- a/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java +++ b/src/org/jetbrains/java/decompiler/modules/decompiler/stats/CatchAllStatement.java @@ -5,7 +5,6 @@ package org.jetbrains.java.decompiler.modules.decompiler.stats; import org.jetbrains.java.decompiler.code.CodeConstants; import org.jetbrains.java.decompiler.main.DecompilerContext; -import org.jetbrains.java.decompiler.util.TextBuffer; import org.jetbrains.java.decompiler.main.collectors.BytecodeMappingTracer; import org.jetbrains.java.decompiler.main.collectors.CounterContainer; import org.jetbrains.java.decompiler.modules.decompiler.DecHelper; @@ -13,8 +12,12 @@ import org.jetbrains.java.decompiler.modules.decompiler.ExprProcessor; import org.jetbrains.java.decompiler.modules.decompiler.StatEdge; import org.jetbrains.java.decompiler.modules.decompiler.exps.VarExprent; import org.jetbrains.java.decompiler.struct.gen.VarType; +import org.jetbrains.java.decompiler.util.TextBuffer; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; public class CatchAllStatement extends Statement { @@ -75,7 +78,7 @@ public class CatchAllStatement extends Statement { for (StatEdge edge : head.getSuccessorEdges(StatEdge.TYPE_EXCEPTION)) { Statement exc = edge.getDestination(); - if (edge.getExceptions() == null && setHandlers.contains(exc) && exc.getLastBasicType() == LASTBASICTYPE_GENERAL) { + if (edge.getExceptions() == null && exc.getLastBasicType() == LASTBASICTYPE_GENERAL && setHandlers.contains(exc)) { List lstSuccs = exc.getSuccessorEdges(STATEDGE_DIRECT_ALL); if (lstSuccs.isEmpty() || lstSuccs.get(0).getType() != StatEdge.TYPE_REGULAR) {