stash
stash copied to clipboard
Use slices package from the stdlib when possible
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