From de4a5bbb5b5dbd221ff024aa0c588b4e0250911a Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 26 Feb 2014 17:25:40 +0400 Subject: [PATCH] refactoring: extracted local function updateEdgeDataForInstruction --- .../cfg/PseudocodeVariableDataCollector.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt index 2684fc8c715..a528075eb90 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt @@ -112,6 +112,16 @@ public class PseudocodeVariableDataCollector( allPreviousInstructions = previousInstructions } + fun updateEdgeDataForInstruction( + previousValue: Edges>?, + newValue: Edges>? + ) { + if (previousValue != newValue && newValue != null) { + changed[0] = true + edgesMap.put(instruction, newValue) + } + } + if (shouldLookInside(instruction, lookInside)) { val functionInstruction = (instruction as LocalFunctionDeclarationInstruction) val subroutinePseudocode = functionInstruction.getBody() @@ -123,12 +133,9 @@ public class PseudocodeVariableDataCollector( val newValue = edgesMap.get(lastInstruction) val updatedValue = if (newValue == null) null else Edges.create( - filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.`in`), - filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.out)) - if (previousValue != updatedValue && updatedValue != null) { - changed[0] = true - edgesMap.put(instruction, updatedValue) - } + filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.`in`), + filterOutVariablesOutOfScope(lastInstruction, instruction, newValue.out)) + updateEdgeDataForInstruction(previousValue, updatedValue) continue } val previousDataValue = edgesMap.get(instruction) @@ -143,10 +150,7 @@ public class PseudocodeVariableDataCollector( } } val mergedData = instructionDataMergeStrategy.execute(instruction, incomingEdgesData) - if (!mergedData.equals(previousDataValue)) { - changed[0] = true - edgesMap.put(instruction, mergedData) - } + updateEdgeDataForInstruction(previousDataValue, mergedData) } }