-
Notifications
You must be signed in to change notification settings - Fork 42
Closed
Labels
t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.
Description
Every schema compilation in actor generate-schema-types performs two full deep clones:
clearAllRequired(schema)/makePropertiesRequired(schema)— each doesstructuredCloneinternallystripTitles(schemaToCompile)— does anotherstructuredCloneat the top of the function
All three functions guarantee immutability (tested), so the second clone in stripTitles is redundant when the caller already holds a disposable copy from step 1.
For the current schemas this has zero practical impact, but it is wasteful and worth cleaning up.
Options
Plan A — { mutate: true } flag on stripTitles
Minimal API change. When the caller already has a disposable clone, it opts out of the internal clone:
export function stripTitles(schema, { mutate = false } = {}) {
const result = mutate ? schema : structuredClone(schema);
// all internal recursive calls pass { mutate: true }
...
}
// call site — schemaToCompile is already a clone, skip second structuredClone
stripTitles(schemaToCompile, { mutate: true })Plan B — combined prepareForCompilation(schema, allOptional) helper
Single clone, applies both the required-field transformation and title-stripping in one pass. Requires extracting private mutating helpers for each transform. Call sites become a single function call but the internal refactor is larger.
Reference
Introduced in #1000.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
t-toolingIssues with this label are in the ownership of the tooling team.Issues with this label are in the ownership of the tooling team.
Type
Fields
Give feedbackNo fields configured for issues without a type.