-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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: Use slices package where possible #6585
Conversation
2nd commit is potentially more controversial, using |
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.
I like it, even the controversial one!
Added even more. FWIW, I was using regexp searches like this to find them 😂 might've missed some, did the ones I could find.
|
9151be6
to
610980c
Compare
610980c
to
794423b
Compare
I was going to suggest semgrep, but apparently they went all proprietary 😕 |
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.
Finally got through all 21 files. I think they are correct changes, if I understand the functions correctly. Thank you for the improvements!
@@ -110,17 +111,12 @@ func parseOptOrder(d *caddyfile.Dispenser, _ any) (any, error) { | |||
} | |||
pos := Positional(d.Val()) | |||
|
|||
newOrder := directiveOrder | |||
// if directive already had an order, drop it | |||
newOrder := slices.DeleteFunc(directiveOrder, func(d string) bool { |
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.
Woah, this is nice.
optsIndex := slices.IndexFunc(serverOpts, func(s serverOptions) bool { | ||
return s.ListenerAddress == "" || slices.Contains(server.Listen, s.ListenerAddress) | ||
}) |
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.
Wow, big win here.
Just a simple cleanup, we can use
slices.Contains()
in a bunch of spots now instead of helper functions to do the simple loop.