Last active
March 13, 2023 09:30
-
-
Save Bruce0203/368e2089e273bd7bb2effa48975f3454 to your computer and use it in GitHub Desktop.
performance optimized forEach in Kotlin (exclude LinkedList case)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun <T> List<T>.fastForEach(callback: (T) -> Unit) { | |
var n = 0 | |
while (n < size) callback(this[n++]) | |
} | |
inline fun <T> Array<T>.fastForEach(callback: (T) -> Unit) { | |
var n = 0 | |
while (n < size) callback(this[n++]) | |
} |
저거 위에 링크 답변좀 부탁드릴게요!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
arm에서는 최대 3배, x86에서는 1.1배 더 빠른 forEach 최적화입니다 @yejunho10