Gordon
11/20/2022, 1:12 PMpublic val Icons.Filled.Circle: ImageVector
get() {
if (_circle != null) {
return _circle!!
}
_circle = materialIcon(name = "Filled.Circle") {
materialPath {
moveTo(12.0f, 2.0f)
curveTo(6.47f, 2.0f, 2.0f, 6.47f, 2.0f, 12.0f)
reflectiveCurveToRelative(4.47f, 10.0f, 10.0f, 10.0f)
reflectiveCurveToRelative(10.0f, -4.47f, 10.0f, -10.0f)
reflectiveCurveTo(17.53f, 2.0f, 12.0f, 2.0f)
close()
}
}
return _circle!!
}
private var _circle: ImageVector? = null
And i wonder why doesn't it just use lazy initialization?
As in something like this:
public val Icons.Filled.Circle: ImageVector by lazy {
materialIcon(name = "Filled.Circle") {
materialPath {
moveTo(12.0f, 2.0f)
curveTo(6.47f, 2.0f, 2.0f, 6.47f, 2.0f, 12.0f)
reflectiveCurveToRelative(4.47f, 10.0f, 10.0f, 10.0f)
reflectiveCurveToRelative(10.0f, -4.47f, 10.0f, -10.0f)
reflectiveCurveTo(17.53f, 2.0f, 12.0f, 2.0f)
close()
}
}
}
Is it just a style issue? Or the second approach has hidden performance cost?Louis Pullen-Freilich [G]
11/20/2022, 6:42 PMLouis Pullen-Freilich [G]
11/20/2022, 6:45 PMlazy
is thread-synchronized, so that definitely will have a performance cost, but you can change the synchronization to none and then the performance overhead is minimalGordon
11/20/2022, 6:46 PMLouis Pullen-Freilich [G]
11/20/2022, 6:47 PM