Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

reducing unnecessary allocations #134

Merged
merged 1 commit into from
Jan 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions dsl/static/src/common/viewChildrenSequences.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ package org.jetbrains.anko
import android.view.*
import java.util.*

fun ViewGroup.forEachChild(f: (View) -> Unit) {
inline fun ViewGroup.forEachChild(f: (View) -> Unit) {
for (i in 0..childCount - 1) {
f(getChildAt(i))
}
}

fun ViewGroup.forEachChildWithIndex(f: (Int, View) -> Unit) {
inline fun ViewGroup.forEachChildWithIndex(f: (Int, View) -> Unit) {
for (i in 0..childCount - 1) {
f(i, getChildAt(i))
}
}

fun ViewGroup.firstChild(predicate: (View) -> Boolean): View {
inline fun ViewGroup.firstChild(predicate: (View) -> Boolean): View {
for (i in 0..childCount - 1) {
val child = getChildAt(i)
if (predicate(child)) {
Expand All @@ -41,7 +41,7 @@ fun ViewGroup.firstChild(predicate: (View) -> Boolean): View {
throw NoSuchElementException("No element matching predicate was found.")
}

fun ViewGroup.firstChildOrNull(predicate: (View) -> Boolean): View? {
inline fun ViewGroup.firstChildOrNull(predicate: (View) -> Boolean): View? {
for (i in 0..childCount - 1) {
val child = getChildAt(i)
if (predicate(child)) {
Expand Down