Copilot commented on code in PR #928:
URL: 
https://github.com/apache/incubator-seata-go/pull/928#discussion_r2394863655


##########
pkg/datasource/sql/undo/executor/executor.go:
##########
@@ -168,21 +168,21 @@ func (b *BaseExecutor) queryCurrentRecords(ctx 
context.Context, conn *sql.Conn)
 }
 
 func (b *BaseExecutor) parsePkValues(rows []types.RowImage, pkNameList 
[]string) map[string][]types.ColumnImage {
+       pkNameSet := make(map[string]struct{}, len(pkNameList))
+       for _, pk := range pkNameList {
+               pkNameSet[strings.ToUpper(pk)] = struct{}{}
+       }
+
        pkValues := make(map[string][]types.ColumnImage)
-       // todo optimize 3 fors
+
        for _, row := range rows {
                for _, column := range row.Columns {
-                       for _, pk := range pkNameList {
-                               if strings.EqualFold(pk, column.ColumnName) {
-                                       values := pkValues[strings.ToUpper(pk)]
-                                       if values == nil {
-                                               values = 
make([]types.ColumnImage, 0)
-                                       }
-                                       values = append(values, column)
-                                       pkValues[pk] = values
-                               }
+                       upperName := strings.ToUpper(column.ColumnName)
+                       if _, exist := pkNameSet[upperName]; exist {
+                               pkValues[upperName] = 
append(pkValues[upperName], column)

Review Comment:
   The pkValues map is keyed by upperName but should use the original primary 
key name from pkNameList to maintain consistency with the function's expected 
behavior. This changes the return value structure from using original case to 
uppercase keys.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to