を作成する「まで」 sec)。 Kotlin私はYourKitと私のコードをプロファイリングするとき、私は/およそ2K(私はIntRangeオブジェクトの膨大な量を持っていたことに気づいた</p> <pre><code>for (x in 0 until bodies.size) bodies[x]() </code></pre> <p>の下に私のforループ<code>until</code>中置の楽しみを使用していた楽しみがIntRangeごみ
ループをint...int
rangeToを使用するように切り替えると、直接ゴミが生成されません。
for (x in 0..bodies.size-1) bodies[x]()
誰かがこの2つの違いを説明できますか?私はInt.until
を伝えることができることは、単に現在のバージョンv1.0.4デベロッパーでthis .. to
public infix fun Int.until(to: Int): IntRange {
val to_ = (to.toLong() - 1).toInt()
if (to_ > to) throw IllegalArgumentException("The to argument value '$to' was too small.")
return this .. to_
}