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 dce6002
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions types/schemas.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,12 @@ 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
})

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

0 comments on commit dce6002

Please sign in to comment.