Skip to content

Commit

Permalink
Use for loop to minimize ops
Browse files Browse the repository at this point in the history
  • Loading branch information
gernest committed Apr 21, 2017
1 parent 7d07fef commit bb84b23
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scope/scope.go
Original file line number Diff line number Diff line change
Expand Up @@ -730,9 +730,11 @@ func HasColumn(e *engine.Engine, modelValue interface{}, column string) bool {

//GetForeignField return the foreign field among the supplied fields.
func GetForeignField(column string, fields []*model.StructField) *model.StructField {
for _, field := range fields {
if field.Name == column || field.DBName == column || field.DBName == util.ToDBName(column) {
return field
for i := 0; i < len(fields); i++ {
if fields[i].Name == column ||
fields[i].DBName == column ||
fields[i].DBName == util.ToDBName(column) {
return fields[i]
}
}
return nil
Expand Down

0 comments on commit bb84b23

Please sign in to comment.