Skip to content

Commit a180e90

Browse files
author
Noam Preil
committed
optimization: compare: avoid initializing config when it's not needed
This makes Schema.Equal ~25% faster in my use case
1 parent f657566 commit a180e90

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arrow/compare.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,6 @@ func CheckMetadata() TypeEqualOption {
4040
// TypeEqual checks if two DataType are the same, optionally checking metadata
4141
// equality for STRUCT types.
4242
func TypeEqual(left, right DataType, opts ...TypeEqualOption) bool {
43-
var cfg typeEqualsConfig
44-
for _, opt := range opts {
45-
opt(&cfg)
46-
}
47-
4843
switch {
4944
case left == right:
5045
return true
@@ -54,6 +49,11 @@ func TypeEqual(left, right DataType, opts ...TypeEqualOption) bool {
5449
return false
5550
}
5651

52+
var cfg typeEqualsConfig
53+
for _, opt := range opts {
54+
opt(&cfg)
55+
}
56+
5757
switch l := left.(type) {
5858
case ExtensionType:
5959
return l.ExtensionEquals(right.(ExtensionType))

0 commit comments

Comments
 (0)