Skip to content

Optimize 1#75

Merged
owjs3901 merged 18 commits intomainfrom
optimize-1
Feb 17, 2026
Merged

Optimize 1#75
owjs3901 merged 18 commits intomainfrom
optimize-1

Conversation

@owjs3901
Copy link
Contributor

No description provided.

owjs3901 and others added 15 commits February 16, 2026 20:01
- Remove unnecessary Result wrapping from generate_filtered_schema (T7)
- Convert option_if_let_else patterns to map_or_else
- Apply let...else syntax for early-return match patterns
- Add backtick formatting to doc comments for types/traits
- Narrow mutex lock scope in schema_type proc macro
- Remove redundant else blocks after return statements
- Use format string interpolation (format!("{x}") over format!("{}", x))
- Add #[allow] annotations for intentional clippy suppressions
- Change pub(crate) to pub where re-exported through module hierarchy

All 1270 tests pass, clippy clean.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ions

Extract 181-line god function into 3 focused helpers:
- build_schema_lookups: register schema name/definition maps
- parse_component_schemas: parse structs/enums into OpenAPI schemas
- build_path_items: process routes into path items with operations

Main function now orchestrates calls + assembles the OpenApi struct (~60 lines).

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Add thread-local depth counter (MAX_DEPTH=32) to parse_type_to_schema_ref_with_schemas.
Prevents stack overflow from deeply nested or circular type references.
Falls back to generic Object schema when depth exceeded.

Implementation uses thread_local Cell<usize> for zero-API-change depth tracking
that works across both direct and indirect recursion paths.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Build a HashMap<file_path, syn::File> once at the start of OpenAPI doc
generation, shared by both parse_component_schemas() and build_path_items().

Before: Each route re-read and re-parsed its source file. For N routes
in M files, this was O(N × file_parse). parse_component_schemas() also
read ALL route files for EACH struct via string search: O(structs × N × file_read).

After: Each unique file parsed exactly once: O(M × file_parse). Struct
lookups use a pre-built name→file index: O(1) per struct.
…ing>

The known_schemas map mapped name→name (value was never used — only
.contains_key() was called). Replacing with HashSet eliminates one
String clone per schema registration and reduces memory usage.

Updated 9 files across the parser module: all function signatures,
call sites, and test code.
@github-actions
Copy link

Changepacks

vespera@Unknown - crates/vespera/Cargo.toml

Maybe you forgot to write the following files to the latest version

vespera_core@Unknown - crates/vespera_core/Cargo.toml

Maybe you forgot to write the following files to the latest version

vespera_macro@Unknown - crates/vespera_macro/Cargo.toml

Maybe you forgot to write the following files to the latest version

@owjs3901 owjs3901 merged commit c9b37c0 into main Feb 17, 2026
2 checks passed
@owjs3901 owjs3901 deleted the optimize-1 branch February 17, 2026 12:52
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