perf(ast_tools): use structs and structs_and_enums iterators where possible#21686
Merged
graphite-app[bot] merged 1 commit intomainfrom Apr 23, 2026
Conversation
This was referenced Apr 23, 2026
Member
Author
This was referenced Apr 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR optimizes ast_tools generators by using Schema::structs() and Schema::structs_and_enums() iterators in places that only need structs or structs+enums, avoiding unnecessary iteration over non-AST type defs (containers/primitives) while keeping generated output unchanged.
Changes:
- Switch generator loops from
schema.types.iter()toschema.structs_and_enums()where only structs/enums are relevant. - Switch
get_idgeneration from iterating all types to iterating onlyschema.structs(). - Update helper function signatures/pattern matches to use
StructOrEnum(and directStructDefwhere appropriate).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tasks/ast_tools/src/generators/scopes_collector.rs | Use structs_and_enums() and StructOrEnum for visitor-method generation. |
| tasks/ast_tools/src/generators/get_id.rs | Iterate only schema.structs() and simplify generation to accept &StructDef. |
| tasks/ast_tools/src/generators/formatter/format.rs | Use structs_and_enums() + StructOrEnum in formatter Format impl generation. |
| tasks/ast_tools/src/generators/formatter/ast_nodes.rs | Use structs_and_enums() + StructOrEnum in AstNode/AstNodes impl generation. |
| tasks/ast_tools/src/generators/ast_builder.rs | Use structs_and_enums() + StructOrEnum for builder method generation selection. |
5c60335 to
960f23d
Compare
7dad5a9 to
8b1e928
Compare
Contributor
Merge activity
|
8b1e928 to
bcd1161
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
…e possible (#21686) Similar to #20944. In loops where a generator is only interested in structs only, or structs and enums, use the `Structs` / `StructsAndEnums` iterators which exit early, rather than pointlessly continuing iterating over all types. Does not alter generated code, only the means by which it's generated.
960f23d to
55546a1
Compare
bcd1161 to
6b1d7f2
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
…e possible (#21686) Similar to #20944. In loops where a generator is only interested in structs only, or structs and enums, use the `Structs` / `StructsAndEnums` iterators which exit early, rather than pointlessly continuing iterating over all types. Does not alter generated code, only the means by which it's generated.
55546a1 to
b69654b
Compare
6b1d7f2 to
d0f8e10
Compare
graphite-app Bot
pushed a commit
that referenced
this pull request
Apr 23, 2026
…e possible (#21686) Similar to #20944. In loops where a generator is only interested in structs only, or structs and enums, use the `Structs` / `StructsAndEnums` iterators which exit early, rather than pointlessly continuing iterating over all types. Does not alter generated code, only the means by which it's generated.
b69654b to
022562c
Compare
…e possible (#21686) Similar to #20944. In loops where a generator is only interested in structs only, or structs and enums, use the `Structs` / `StructsAndEnums` iterators which exit early, rather than pointlessly continuing iterating over all types. Does not alter generated code, only the means by which it's generated.
d0f8e10 to
8e421a3
Compare
022562c to
b18a0cf
Compare
Base automatically changed from
om/02-14-refactor_ast_tools_simplify_astkind_generator
to
main
April 23, 2026 18:49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Similar to #20944. In loops where a generator is only interested in structs only, or structs and enums, use the
Structs/StructsAndEnumsiterators which exit early, rather than pointlessly continuing iterating over all types.Does not alter generated code, only the means by which it's generated.