Skip to content

Commit 60d3c68

Browse files
committed
Avoid generating URI when checking unique
The URI generation is slow and unnecessary just to compare two fields. This reduces extra allocations down to 0 during registration. Signed-off-by: Derek McGowan <derek@mcg.dev>
1 parent c9ccfc6 commit 60d3c68

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

plugin.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ func (registry Registry) Register(r *Registration) Registry {
170170

171171
func checkUnique(registry Registry, r *Registration) error {
172172
for _, registered := range registry {
173-
if r.URI() == registered.URI() {
173+
if r.Type == registered.Type && r.ID == registered.ID {
174174
return fmt.Errorf("%s: %w", r.URI(), ErrIDRegistered)
175175
}
176176
}

0 commit comments

Comments
 (0)