Skip to content

Commit

Permalink
Improve performance a little bit
Browse files Browse the repository at this point in the history
  • Loading branch information
b97tsk committed Jan 30, 2024
1 parent 5ff38be commit 7b44fa7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion difference.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func Difference[E Elem[E]](z, x, y Set[E]) Set[E] {
inv := false

for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
inv = !inv
}
Expand Down
2 changes: 1 addition & 1 deletion intersection.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Intersection[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
}

Expand Down
2 changes: 1 addition & 1 deletion issubsetof.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ func (x Set[E]) IsSubsetOf(y Set[E]) bool {
inv := false

for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
inv = !inv
}
Expand Down
2 changes: 1 addition & 1 deletion overlap.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import "sort"
// Overlaps reports whether the intersection of x and y is not empty.
func (x Set[E]) Overlaps(y Set[E]) bool {
for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
}

Expand Down
2 changes: 1 addition & 1 deletion symdiff.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func SymmetricDifference[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
}

Expand Down
2 changes: 1 addition & 1 deletion union.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func Union[E Elem[E]](z, x, y Set[E]) Set[E] {
z = z[:0]

for {
if len(x) < len(y) {
if len(x) == 0 {
x, y = y, x
}

Expand Down

0 comments on commit 7b44fa7

Please sign in to comment.