Skip to content

Commit

Permalink
Optimize MutableObjectAdapter.remove(element: T)
Browse files Browse the repository at this point in the history
  • Loading branch information
nielsvanvelzen committed May 22, 2024
1 parent ef07ebd commit 1bad4c0
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ open class MutableObjectAdapter<T : Any> : ObjectAdapter, Iterable<T> {
}

fun remove(element: T): Boolean {
val removed = data.remove(element)
if (removed) notifyChanged()
return removed
val index = indexOf(element)
if (index == -1) return false
return removeAt(index, 1)
}

fun removeAt(index: Int, length: Int = 1): Boolean {
Expand Down

0 comments on commit 1bad4c0

Please sign in to comment.