When a class is marked as a data class, would the ...
# android
z
When a class is marked as a data class, would the generated functions result in the APK size to increase? or would proguard remove it?
e
proguard will remove
componentN
and
copy
if they're not used. it won't remove
equals
,
hashCode
,
toString
.
👍 2
z
Would there be a noticeable increase in APK size with many data classes
e
if you were going to hand-write those methods anyway then there's no difference. if you are somehow in a situation where you don't need those methods (which is hard to statically prove, so proguard doesn't) then you can either not use data classes or use a plugin like https://twitter.com/lightdelay/status/1490722524014985217 to delete them
that plugin doesn't seem to be public. you could message the author, or manually override
equals
,
hashCode
,
toString
to just call
super
, or use ASM manipulation instead of a Kotlin plugin, e.g. https://www.reddit.com/comments/x8z9r1/-/innw882/ could easily be modified for that purpose
s