Closed JakeWharton closed 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.
Enum.values()
clone
peek
next
Kotlin's
Enum.values()
function delegates directly to Java'sEnum.values()
whichclone
s an internal array on every access. Cache the array so that this allocation only occurs once rather than on each call topeek
ornext
.