Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add util.Keys and util.KeysSorted #7285

Merged

Conversation

anderseknert
Copy link
Member

And use them to reduce imperative boilerplate throughout the codebase.

Additionally, replace use of sort.Slice with slices.SortFunc which is more efficient since it is generic and as such avoids allocations related to interface{} casts.

Also a few performance-related minor fixes, but not the main theme of this PR.

BenchmarkRegalLintingItself-10 before / after
1832684458 ns/op    3453470360 B/op    66125422 allocs/op
1826601250 ns/op    3449619024 B/op    65999164 allocs/op

And use them to reduce imperative boilerplate throughout
the codebase.

Additionally, replace use of sort.Slice with slices.SortFunc
which is more efficient since it is generic and as such avoids
allocations related to `interface{}` casts.

Also a few performance-related minor fixes, but not the main
theme of this PR.

```
BenchmarkRegalLintingItself-10 before / after
1832684458 ns/op    3453470360 B/op    66125422 allocs/op
1826601250 ns/op    3449619024 B/op    65999164 allocs/op
````

Signed-off-by: Anders Eknert <[email protected]>
@anderseknert anderseknert merged commit 622434d into open-policy-agent:main Jan 21, 2025
28 checks passed
@anderseknert anderseknert deleted the keys-and-keys-sorted branch January 21, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants