Skip to content

Simplify Inheritable.computeCanonicalEnclosingContainer. #4047

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

srawlins
Copy link
Member

@srawlins srawlins commented May 6, 2025

This method is very complicated, so any simplification is handy.

  • It used to start with a very long if-then body, and the else body was rather lost far below. Instead we can implement some simple short circuiting, if we're not dealing with an inherited element.
  • It used to carry around a found variable, breaking the loop when it found a container. But it's simpler to just return at that point.
  • The final return value is always null, representing a state where no canonical enclosing container is found. Just return null to simplify understandability.

Otherwise this is a no-op.

This method is very complicated, so any simplification is handy.

* It used to start with a very long if-then body, and the else body was rather
  lost far below. Instead we can implement some simple short circuiting, if
  we're not dealing with an inherited element.
* It used to carry around a `found` variable, breaking the loop when it found a
  container. But it's simpler to just return at that point.
* The final return value is always `null`, representing a state where no
  canonical enclosing container is found. Just return `null` to simplify
  understandability.

Otherwise this is a no-op.
@srawlins srawlins requested a review from szakarias May 6, 2025 05:57
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.

1 participant