Plugins: Optimize creation of Golang errors and slices (#69448)

* tidy up

* fix tests
This commit is contained in:
Will Browne
2023-06-07 17:22:43 +02:00
committed by GitHub
parent 8a8b5da1ee
commit 1fd4953833
13 changed files with 72 additions and 66 deletions
+4 -2
View File
@@ -96,8 +96,10 @@ func (s *Service) plugin(ctx context.Context, pluginID string) (*plugins.Plugin,
// availablePlugins returns all non-decommissioned plugins from the registry sorted by alphabetic order on `plugin.ID`
func (s *Service) availablePlugins(ctx context.Context) []*plugins.Plugin {
var res []*plugins.Plugin
for _, p := range s.pluginRegistry.Plugins(ctx) {
ps := s.pluginRegistry.Plugins(ctx)
res := make([]*plugins.Plugin, 0, len(ps))
for _, p := range ps {
if !p.IsDecommissioned() {
res = append(res, p)
}