refactor: introduce clone helper for slice copying#784
Draft
d-enk wants to merge 1 commit into
Draft
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #784 +/- ##
==========================================
+ Coverage 94.18% 94.27% +0.08%
==========================================
Files 18 18
Lines 2873 2848 -25
==========================================
- Hits 2706 2685 -21
+ Misses 151 149 -2
+ Partials 16 14 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
d50307f to
3ab8107
Compare
Contributor
Author
|
Draft reason golang/go#77287 |
- Add clone() function that returns a shallow copy without preserving nilness
is guaranteed to be inlined by the compiler (verified with -gcflags=-m)
(separate from Clone() which preserves nilness - library convention is to return empty slice)
- Simplify Clone() to delegate to clone() for non-nil collections
- Refactor Chunk, Sliding, Drop, DropRight, DropWhile, DropRightWhile, Take, TakeWhile, Replace, Trim to use clone()
- Update SamplesBy and debounce.reset to use clone()
- Replace make(Slice, 0) with Slice{} for return statements
Also
- Some redundant checks have been removed in Take, NthOrEmpty
- Simplify TrimPrefix and TrimSuffix loops
- Micro-optimize Replace() by reordering condition to short-circuit on n != 0 first
(TODO: consider adding early break when n reaches 0)
3ab8107 to
d873409
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
is guaranteed to be inlined by the compiler (verified with -gcflags=-m)
(separate from Clone() which preserves nilness - library convention is to return empty slice)
Also
(TODO: consider adding early break when n reaches 0)