Skip to content

Commit

Permalink
chore: Preallocate space for slices with known size (argoproj-labs#575)
Browse files Browse the repository at this point in the history
Signed-off-by: satoru <satorulogic@gmail.com>
Signed-off-by: Jesse Bye <8467862+jessebye@users.noreply.github.com>
  • Loading branch information
suzaku authored and jessebye committed Sep 1, 2023
1 parent deab5b3 commit 31c0152
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pkg/registry/endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,9 @@ func SetRegistryEndpointCredentials(prefix, credentials string) error {

// ConfiguredEndpoints returns a list of prefixes that are configured
func ConfiguredEndpoints() []string {
r := []string{}
registryLock.RLock()
defer registryLock.RUnlock()
r := make([]string, 0, len(registries))
for _, v := range registries {
r = append(r, v.RegistryPrefix)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/tag/tag.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ func (il ImageTagList) Add(tag *ImageTag) {

// SortByName returns an array of ImageTag objects, sorted by the tag's name
func (il ImageTagList) SortAlphabetically() SortableImageTagList {
sil := SortableImageTagList{}
sil := make(SortableImageTagList, 0, len(il.items))
for _, v := range il.items {
sil = append(sil, v)
}
Expand All @@ -136,7 +136,7 @@ func (il ImageTagList) SortAlphabetically() SortableImageTagList {

// SortByDate returns a SortableImageTagList, sorted by the tag's date
func (il ImageTagList) SortByDate() SortableImageTagList {
sil := SortableImageTagList{}
sil := make(SortableImageTagList, 0, len(il.items))
for _, v := range il.items {
sil = append(sil, v)
}
Expand Down

0 comments on commit 31c0152

Please sign in to comment.