Skip to content

refactor: flatten bind_json.rs to one pass without state structs #10791

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

Merged
merged 2 commits into from
Jun 24, 2025

Conversation

DaniPopes
Copy link
Member

Refactored the bind_json implementation to eliminate the intermediate state structs and flatten the logic into a single pass through the workflow.

Previously the implementation used three state structs (PreprocessedState, StructsState, ResolvedState) that were passed sequentially through the workflow. This change consolidates all logic into methods on BindJsonArgs, making the code more straightforward while preserving the same functionality.

The main run() method now clearly shows the 4 steps:

  1. Read and preprocess sources
  2. Handle potentially invalid bindings
  3. Find structs and resolve conflicts
  4. Write bindings

All the original logic for preprocessing, finding structs, resolving conflicts, and writing bindings remains intact.

Refactored the bind_json implementation to eliminate the intermediate
state structs (PreprocessedState, StructsState, ResolvedState) and
flatten the logic into a single pass through the workflow.

All logic now resides within methods on BindJsonArgs, making the code
more straightforward while preserving the same functionality.
- Change &PathBuf to &Path in function parameter
- Remove unnecessary borrows
- Change &mut Vec to &mut slice
- Add Path import
@grandizzy grandizzy requested a review from 0xrusowsky June 17, 2025 18:43
Copy link
Contributor

@0xrusowsky 0xrusowsky left a comment

Choose a reason for hiding this comment

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

LGTM

agreed that the code is easier to follow now 👍

@DaniPopes DaniPopes merged commit a3b6b33 into master Jun 24, 2025
42 of 44 checks passed
@DaniPopes DaniPopes deleted the dani/bind-json-one-pass branch June 24, 2025 15:04
@github-project-automation github-project-automation bot moved this to Done in Foundry Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants