Skip to content

Commit

Permalink
use slices pkg to search for candidates
Browse files Browse the repository at this point in the history
  • Loading branch information
joshmeranda committed Nov 25, 2024
1 parent 6c28360 commit 335ac95
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions types/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,11 @@ func (s *Schemas) doAddSchema(schema Schema, replace bool) *Schemas {
schemas[schema.ID] = &schema

if replace {
for i, candidate := range s.schemas {
if candidate.ID == schema.ID {
s.schemas[i] = &schema
break
}
}
i := slices.IndexFunc(s.schemas, func(candidate *Schema) bool {
return candidate.ID == schema.ID
})

s.schemas[i] = &schema
} else {
s.schemas = append(s.schemas, &schema)
}
Expand Down

0 comments on commit 335ac95

Please sign in to comment.