Skip to content

Commit

Permalink
chore: slice loop replace (#688)
Browse files Browse the repository at this point in the history
* chore: slice loop replace

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>

* chore: use copy instead of a loop

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>

---------

Signed-off-by: guoguangwu <guoguangwu@magic-shield.com>
  • Loading branch information
testwill authored Dec 2, 2023
1 parent 34f1548 commit 009d9dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 12 deletions.
4 changes: 1 addition & 3 deletions pkg/backends/healthcheck/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ func (o *Options) Clone() *Options {
}
if len(o.ExpectedCodes) > 0 {
c.ExpectedCodes = make([]int, len(o.ExpectedCodes))
for i, v := range o.ExpectedCodes {
c.ExpectedCodes[i] = v
}
copy(c.ExpectedCodes, o.ExpectedCodes)
}
c.md = o.md
c.hasExpectedBody = o.hasExpectedBody
Expand Down
4 changes: 1 addition & 3 deletions pkg/proxy/headers/result_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ func MergeResultHeaderVals(h1, h2 string) string {
if len(r1.Fetched) == 0 {
r1.Fetched = r2.Fetched
} else {
for _, extent := range r2.Fetched {
r1.Fetched = append(r1.Fetched, extent)
}
r1.Fetched = append(r1.Fetched, r2.Fetched...)
r1.Fetched = r1.Fetched.Compress(0)
}

Expand Down
8 changes: 2 additions & 6 deletions pkg/timeseries/timerangequery.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,12 @@ func (trq *TimeRangeQuery) Clone() *TimeRangeQuery {

if trq.TagFieldDefintions != nil {
t.TagFieldDefintions = make([]FieldDefinition, len(trq.TagFieldDefintions))
for i, fd := range trq.TagFieldDefintions {
t.TagFieldDefintions[i] = fd
}
copy(t.TagFieldDefintions, trq.TagFieldDefintions)
}

if trq.ValueFieldDefinitions != nil {
t.ValueFieldDefinitions = make([]FieldDefinition, len(trq.ValueFieldDefinitions))
for i, fd := range trq.ValueFieldDefinitions {
t.ValueFieldDefinitions[i] = fd
}
copy(t.ValueFieldDefinitions, trq.ValueFieldDefinitions)
}

if trq.TemplateURL != nil {
Expand Down

0 comments on commit 009d9dd

Please sign in to comment.