Skip to content

Commit

Permalink
parser: use slices.Equal to simple code (#54117)
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Jun 20, 2024
1 parent a33a868 commit 5377c6f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
1 change: 1 addition & 0 deletions pkg/parser/types/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ go_library(
"//pkg/parser/mysql",
"//pkg/parser/terror",
"@com_github_cznic_mathutil//:mathutil",
"@org_golang_x_exp//slices",
],
)

Expand Down
10 changes: 3 additions & 7 deletions pkg/parser/types/field_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/pingcap/tidb/pkg/parser/charset"
"github.com/pingcap/tidb/pkg/parser/format"
"github.com/pingcap/tidb/pkg/parser/mysql"
"golang.org/x/exp/slices"
)

// UnspecifiedLength is unspecified length.
Expand Down Expand Up @@ -297,15 +298,10 @@ func (ft *FieldType) Equal(other *FieldType) bool {
ft.collate == other.collate &&
flenEqual &&
mysql.HasUnsignedFlag(ft.flag) == mysql.HasUnsignedFlag(other.flag)
if !partialEqual || len(ft.elems) != len(other.elems) {
if !partialEqual {
return false
}
for i := range ft.elems {
if ft.elems[i] != other.elems[i] {
return false
}
}
return true
return slices.Equal(ft.elems, other.elems)
}

// PartialEqual checks whether two FieldType objects are equal.
Expand Down

0 comments on commit 5377c6f

Please sign in to comment.