optimize attributes plus

This commit is contained in:
Alexander Nozik 2024-07-07 11:06:20 +03:00
parent 2d309e050b
commit 6e24b563b2

View File

@ -140,4 +140,8 @@ public fun <A : Attribute<Unit>> Attributes(
attribute: A, attribute: A,
): Attributes = MapAttributes(mapOf(attribute to Unit)) ): Attributes = MapAttributes(mapOf(attribute to Unit))
public operator fun Attributes.plus(other: Attributes): Attributes = MapAttributes(content + other.content) public operator fun Attributes.plus(other: Attributes): Attributes = when{
isEmpty() -> other
other.isEmpty() -> this
else -> MapAttributes(content + other.content)
}