Skip to content

Commit

Permalink
Slight improvements to code
Browse files Browse the repository at this point in the history
  • Loading branch information
rihi committed Jan 18, 2024
1 parent 5ae3cb5 commit f2b4092
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions decompiler/backend/codevisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,13 @@ def visit_condition_node(self, node: ast_nodes.ConditionNode) -> str:

swap_branches = None

# if only one branch is a condition node we want to swap
# if only one branch is a condition node, we want to decide swapping by which branch is a condition node
if isinstance(false_child, ast_nodes.ConditionNode) != isinstance(true_child, ast_nodes.ConditionNode):
swap_branches = swap_branches or not isinstance(false_child, ast_nodes.ConditionNode)
swap_branches = not isinstance(false_child, ast_nodes.ConditionNode)

length_comparisons = {"none": None, "smallest": len(true_str) > len(false_str), "largest": len(true_str) < len(false_str)}
# if we haven't already decided on swapping (swap_branches is None), decide by length
if swap_branches is None:
length_comparisons = {"none": None, "smallest": len(true_str) > len(false_str), "largest": len(true_str) < len(false_str)}
swap_branches = length_comparisons[self._preferred_true_branch]

if swap_branches:
Expand Down

0 comments on commit f2b4092

Please sign in to comment.