romainguy / pathway

A set of APIs to manipulate graphics paths on Android.
Apache License 2.0
197 stars 3 forks source link

Cache PathSegment.Type values to avoid allocation #1

Closed JakeWharton closed 2 years ago

JakeWharton commented 2 years ago

Kotlin's Enum.values() function delegates directly to Java's Enum.values() which clones an internal array on every access. Cache the array so that this allocation only occurs once rather than on each call to peek or next.