Skip to content

Commit

Permalink
Avoid size computation when comparing with empty sets
Browse files Browse the repository at this point in the history
  • Loading branch information
ericeil committed Dec 24, 2024
1 parent 752d3fd commit d3fcd9d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ internal sealed class AbstractTreapMap<@Treapable K, V, @Treapable S : AbstractT
return when {
otherMap == null -> false
otherMap === this -> true
otherMap.isEmpty() -> false
else -> otherMap.useAsTreap(
{ otherTreap -> this.self.deepEquals(otherTreap) },
{ other.size == this.size && other.entries.all { this.containsEntry(it) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ internal sealed class AbstractTreapSet<@Treapable E, S : AbstractTreapSet<E, S>>
other == null -> false
this === other -> true
other !is Set<*> -> false
other.isEmpty() -> false
else -> (other as Set<E>).useAsTreap(
{ otherTreap -> this.self.deepEquals(otherTreap) },
{ this.size == other.size && this.containsAll(other) }
Expand Down

0 comments on commit d3fcd9d

Please sign in to comment.