-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
chore: improve GetField logic #897
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
📢 Thoughts on this report? Let us know!. |
internal/corazawaf/transaction.go
Outdated
for i, c := range matches { | ||
// in the most common scenario filteredMatches length will be | ||
// the same as matches length, so we avoid allocating per result | ||
filteredMatches := make([]types.MatchData, len(matches)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think it's good to use make([], 0, len)
and append
since it basically allows Go to take care of the filteredCount
variable while still preallocating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done!
Thanks @jptosso. Specifically this line coraza/internal/corazawaf/transaction.go Line 582 in 4b1b82d
|
That line was deleted |
I like the implementation... can we find tests for the else paths? |
Reduce number of allocations, loops, and complexity.