[Pitch] Enum Quality of Life Improvements

CasePaths used to use reflection, but using a mirror is about 1,000x slower than manually writing an if case let. This may not be a big deal for a casual match/extraction, but can add up quickly in a hot code path. These days CasePaths uses the Swift runtime metadata, instead, and is only about 2–5x slower than an if case let.

As nice as it is to have runtime metadata around to implement this functionality ourselves in a performant-enough way, this really is a feature that should be built into the language, given that key paths are built into the language and are used all over the place these days, like all of the dynamic member lookups in SwiftUI.

21 Likes