Skip to content

Commit

Permalink
Create empty slices with expected capacity
Browse files Browse the repository at this point in the history
  • Loading branch information
dangra committed Jan 25, 2023
1 parent c3f9900 commit 5970138
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func (hs *HTTPService) toMachineService() *api.MachineService {
}

func (s *Service) toMachineService() *api.MachineService {
checks := make([]api.Check, 0)
checks := make([]api.Check, 0, len(s.TCPChecks)+len(s.HTTPChecks))
for _, tc := range s.TCPChecks {
checks = append(checks, *tc.toCheck())
}
Expand Down Expand Up @@ -259,7 +259,7 @@ func (hc *ServiceHTTPCheck) toCheck() *api.Check {
}
check.HTTPSkipTLSVerify = api.Pointer(hc.TLSSkipVerify)
if len(hc.Headers) > 0 {
check.HTTPHeaders = make([]api.HTTPHeader, len(hc.Headers))
check.HTTPHeaders = make([]api.HTTPHeader, 0, len(hc.Headers))
for name, value := range hc.Headers {
check.HTTPHeaders = append(check.HTTPHeaders, api.HTTPHeader{Name: name, Value: value})
}
Expand Down

0 comments on commit 5970138

Please sign in to comment.