plugin: optimize the check for the last registration

Signed-off-by: Iceber Gu <wei.cai-nat@daocloud.io>
This commit is contained in:
Iceber Gu 2021-04-30 23:32:04 +08:00
parent 3dad67eedb
commit 98f5922b5e

View File

@ -171,15 +171,11 @@ func Register(r *Registration) {
panic(err)
}
var last bool
for _, requires := range r.Requires {
if requires == "*" {
last = true
if requires == "*" && len(r.Requires) != 1 {
panic(ErrInvalidRequires)
}
}
if last && len(r.Requires) != 1 {
panic(ErrInvalidRequires)
}
register.r = append(register.r, r)
}