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

Use slices package from the stdlib when possible #5360

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

its-josh4
Copy link
Contributor

Found that pkg/sliceutil had a lot of duplicate functionality with the slices package that is now in the stdlib, so I replaced these methods with the ones from the stdlib:

  • sliceutil.Contains
  • sliceutil.Index

Additionally, made 2 small perf improvements to the sliceutil package:

  • sliceutil.AppendUniques: use slices.Grow to grow the capacity of the slice (if needed) just once. This will make it so the function will cause at most 1 allocation in the heap, no matter how many items are being added
  • sliceutil.Unique: when allocating the lookup map and destination slice, pre-allocate them with max possible capacity to avoid re-allocations

@WithoutPants WithoutPants added the chore Pull requests for refactoring and admin work label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Pull requests for refactoring and admin work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants