Skip to content

CasePath protocol - #254

Draft
stephencelis wants to merge 13 commits into
26from
protocol-case-paths
Draft

CasePath protocol#254
stephencelis wants to merge 13 commits into
26from
protocol-case-paths

Conversation

@stephencelis

Copy link
Copy Markdown
Member

This is another 2.0-breaking change. @CasePathable will generate concrete CasePath conformances per case, and CaseKeyPath will be generic over that concrete type instead.

For end-users of case paths, like ComposableArchitecture, SwiftNavigation, Parsing, and more, this change should be more or less transparent.

To library users writing code against case key paths, the main change:

-f<Root, Value>(_: CaseKeyPath<Root, Value>)
+f<Root, Value, Path: CasePath<Root, Value>>(_: CaseKeyPath<Root, Path>)

1.0's case key paths were more ergonomic than the original AnyCasePath struct, but generally a bit slower. Not so slow to drop the concept entirely, but worth addressing. This PR eliminates pretty much all overhead of case key paths. Direct benchmarks are hundreds of times faster per extract/embed, while library usage sees a nice real world speedup as well (store scoping is about 3x faster in TCA26 on this branch).

@stephencelis
stephencelis requested a review from mbrandonw August 26, 2026 22:05
@stephencelis
stephencelis changed the base branch from main to 26 August 26, 2026 22:06
@stephencelis stephencelis added this to the 2.0 milestone Aug 26, 2026
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