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

Refactor flexbox layout algorithm into multiple functions #43

Closed
TimJentzsch opened this issue May 15, 2022 · 1 comment
Closed

Refactor flexbox layout algorithm into multiple functions #43

TimJentzsch opened this issue May 15, 2022 · 1 comment
Assignees
Labels
code quality Make the code cleaner or prettier. good first issue Good for newcomers

Comments

@TimJentzsch
Copy link
Collaborator

TimJentzsch commented May 15, 2022

What problem does this solve or what need does it fill?

The current implementation is very tightly coupled and will be hard to maintain in the future. The compute_internal function has about 1k lines of code-- this will not be sustainable in the long run and might lead to code duplication once we have multiple layout algorithms.

What solution would you like?

The compute_internal function should be split up into multiple smaller functions that correspond to the steps of the layout algorithm. Each function should clearly document the spec that it implements, ideally also linking to the spec docs. The original function can then simply call the steps one-by-one, similar to the template method pattern.

We need to carefully watch how this affects performance using benchmarks, probably adding #[inline] annotations to each step.

In the future we should also have tests for each step to make sure that we fully correspond to the spec. This can be done in a separate PR though.

Acceptance Criteria

  • compute_internal has been separated into multiple functions, corresponding to the steps of the layout algorithm.
  • #[allow(clippy::cognitive_complexity)] has been removed.
  • Each function is documented, referencing the flexbox specs.
  • No functional changes have been made.
  • The benchmarks don't show any major performance regressions.

Additional context

This will be the first step towards improving the functionality of the layout algorithm with #39.

@TimJentzsch TimJentzsch added good first issue Good for newcomers code quality Make the code cleaner or prettier. labels May 15, 2022
@TimJentzsch TimJentzsch self-assigned this May 16, 2022
@alice-i-cecile
Copy link
Collaborator

Closed by #88.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Make the code cleaner or prettier. good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants