Skip to content

P8: Replace Context lazy var rule state with optional let #554

@Jason-Abbott

Description

@Jason-Abbott

Location: Sources/SwiftiomaticKit/Support/Context.swift:57-74

Context declares 17 lazy var properties for compact-pipeline rule state. Each lazy access compiles to a per-property branch + atomic init flag check on every access.

Potential performance benefit

For hot rules accessed thousands of times per file, the per-property lazy gating adds up. Replacing with optional let initialized in Context.init only when the matching rule is enabled (using P1's enabledRules) gives a single nil check on access and skips initialization for disabled rules entirely.

Reason deferred

Mechanical refactor across 17 sites; needs P1 already landed (which it now is). Easy follow-up but bundling more state-init logic into Context.init warrants its own PR with measurements showing the lazy gating is actually visible in profiles.

👾 This issue is managed by Jig. Edits made here will be overwritten.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions