Skip to content

Commit

Permalink
refac(SFS-1439): use slices.Reverse
Browse files Browse the repository at this point in the history
Co-authored-by: cezar-guimaraes <[email protected]>
  • Loading branch information
biancasilvavtex and cezar-guimaraes committed Sep 13, 2024
1 parent 0a86127 commit 6c07acd
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions custom_cel/lists.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/google/cel-go/common/types/traits"
"github.com/google/cel-go/parser"
"k8s.io/apiserver/pkg/cel/library"
"slices"
"sort"
)

Expand Down Expand Up @@ -197,10 +198,7 @@ func makeReverse(itemsVal ref.Val) ref.Val {
orderedItems = append(orderedItems, it.Next())
}

for i := len(orderedItems)/2 - 1; i >= 0; i-- {
opp := len(orderedItems) - 1 - i
orderedItems[i], orderedItems[opp] = orderedItems[opp], orderedItems[i]
}
slices.Reverse(orderedItems)

return types.NewDynamicList(types.DefaultTypeAdapter, orderedItems)
}

0 comments on commit 6c07acd

Please sign in to comment.