[collab] do not create new set when not needed

GitOrigin-RevId: 0bb2b7cd06778faf2bf499f267a057a3066498a0
This commit is contained in:
Ivan Semenov
2023-01-19 16:00:48 +01:00
committed by intellij-monorepo-bot
parent 703f13f1d9
commit de3ff8eea8

View File

@@ -2,8 +2,10 @@
package com.intellij.collaboration.util
class CollectionDelta<out T>(oldCollection: Collection<T>, val newCollection: Collection<T>) {
val newItems: Collection<T> = newCollection - oldCollection.toSet()
val removedItems: Collection<T> = oldCollection - newCollection.toSet()
val newItems: Collection<T> = newCollection - oldCollection.asSet()
val removedItems: Collection<T> = oldCollection - newCollection.asSet()
private fun <T> Collection<T>.asSet() = ((this as? Set<T>) ?: toSet())
val isEmpty = newItems.isEmpty() && removedItems.isEmpty()
}