go /
wiki /
ac40441c8110bd221a451ae37ee6dc1b7ce9c168 SliceTricks: use builtin clear
After filtering without allocating, it's recommended to loop over the underlying slice `a` and setting all unneeded values to `nil` manually if they're to be gc'ed.
Instead, one might simply use the builtin `clear` on the sub-slice starting at the end of `b`.
Change-Id: I25c180bbbccf989ffa0d1fadd54e3a20ff9504c8
GitHub-Last-Rev: ce32262e3ee11baecef0bfd425c8c30096e1e182
GitHub-Pull-Request: golang/wiki#24
Reviewed-on: https://go-review.googlesource.com/c/wiki/+/609517
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
1 file changed