Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwitchExtractor Improvement #424

Merged
merged 5 commits into from
Jun 24, 2024
Merged

Conversation

ebehner
Copy link
Collaborator

@ebehner ebehner commented Jun 21, 2024

First, the switch-extractor did not consider sequence nodes with a non-trivial reaching-condition. Therefore, we did not extract some switches leading to fewer cases or not the ability to merge cases.
Second, there was a minor bug, because we extracted switches from conditions nodes even if they were children of a sequence node with a non-trivial reaching-condition.

@ebehner ebehner self-assigned this Jun 21, 2024
self._current_cond_node.clean()

def _try_to_extract_switch_from_branch(self, branch: Union[TrueNode, FalseNode]) -> None:
def _switch_can_be_extracted(self, switch_node: SwitchNode) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the function name is a bit misleading, indicating that it is only checked if the extraction is possible or not. Instead, the extraction is actually performed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, I still don't particularly like the naming, but sure :D

self.asforest.extract_branch_from_condition_node(self._current_cond_node, branch, False)
self.asforest.extract_branch_from_condition_node(condition_node, branch, False)

def _extract_switch_from_first_or_last_child_of(self, sequence_node: SeqNode, condition: LogicCondition) -> bool:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw. and regarding my above comment: Here you are also returning True/False in case of succeeded or failed extraction without the function being names as above

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

@steffenenders steffenenders enabled auto-merge (squash) June 24, 2024 11:38
@steffenenders steffenenders merged commit 68d1d13 into main Jun 24, 2024
1 check passed
@steffenenders steffenenders deleted the switch-extractor-improvement branch June 24, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants