Skip to content

Commit

Permalink
add comment to explain why queries and checks are copied
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Jul 28, 2023
1 parent c155119 commit 1049ce3
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions policy/policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ func (p *Policy) updateAllChecksums(ctx context.Context,
}

// CHECKS (must be sorted)
// copy checks to keep the original order and only sort it for the purpose of checksum generation
checks := make([]*explorer.Mquery, len(group.Checks))
copy(checks, group.Checks)
sort.Slice(checks, func(i, j int) bool {
Expand Down Expand Up @@ -484,6 +485,7 @@ func (p *Policy) updateAllChecksums(ctx context.Context,
}

// DATA (must be sorted)
// copy checks to keep the original order and only sort it for the purpose of checksum generation
queries := make([]*explorer.Mquery, len(group.Queries))
copy(queries, group.Queries)
sort.Slice(queries, func(i, j int) bool {
Expand Down

0 comments on commit 1049ce3

Please sign in to comment.