Swiftfall icon indicating copy to clipboard operation
Swiftfall copied to clipboard

Card type could be a class rather than a struct

Open shawnrc opened this issue 6 years ago • 2 comments

Cards are entirely immutable as is, and with like 13,000+ of them potentially in use, it doesn't really make sense to copy them around as much as they're currently forced to be. Consider making Card a class.

shawnrc avatar Mar 10 '18 05:03 shawnrc

I dont think it should be a class. Swift best practice is to keep data as structs as long as you dont have a reason to use a reference type (like when you want to be able to modify a existing piece of data). And also, value types aren't always copied. The standard library tries to use copy-on-write for value types when able to, so chances are there are not actually any copies made if you just pass them around, specially for immutable data.

I dont think we should use classes unless we can see some weird performance issues related to using value types.

naknut avatar Jul 02 '19 22:07 naknut

Totally agree

Lemonbrush avatar Dec 23 '22 20:12 Lemonbrush