Skip to content

Improve decision tree generated code for if-else branches #4522

@giacomocavalieri

Description

@giacomocavalieri

Generating code from the decision tree can result in this kind of structure on the JS target:

if (cond) {
  // ...
} else {
  if (other_cond) {
    // ...
  } else {
    // ...
  }
}

It would be a nice touch if the generated code looked like this instead:

if (cond) {
  // ...
} else if (other_cond) {
  // ...
} else {
  // ...
}

This is not as straightforward as it seems since sometimes we might have variable definitions in between an else and the nested if, making it impossible to collapse into an else if.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions