[swift-evolution] [Pitch] Hashable types on RawRepresentable enums or a protocol for custom enum-like types

Joe Groff jgroff at apple.com
Tue Oct 4 13:16:08 CDT 2016

> On Oct 4, 2016, at 11:07 AM, Adrian Zubarev <adrian.zubarev at devandartist.com> wrote:
> Doesn’t this imply more performance cost? Don’t get me wrong but the value here is not fixed and computed all over again which might waste resources if the calculation is complicated. Sure we could build some workarounds here and there, but the codebase won’t get any prettier after that.
I doubt it. Formally, integer and string literals are also constructor calls, but they're inlined and constant-folded away in most cases. A struct construction is also likely to be optimized. The code pattern I presented is exactly what the compiler automatically generates when you use the sugar syntax.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161004/50ebe95c/attachment.html>

More information about the swift-evolution mailing list