Skip to content

perf: preallocate result slice in RangeWithSteps#820

Merged
samber merged 1 commit intosamber:masterfrom
d-enk:perf-range-with-step
Feb 25, 2026
Merged

perf: preallocate result slice in RangeWithSteps#820
samber merged 1 commit intosamber:masterfrom
d-enk:perf-range-with-step

Conversation

@d-enk
Copy link
Contributor

@d-enk d-enk commented Feb 25, 2026

  • RangeWithSteps now preallocates result slice using math.Ceil for better performance
  • Fix edge cases for floating point values with small steps
  • Add test cases for float and custom type validation
  • Rename TestRangeClose → TestRangeWithSteps for consistency
  • Simplify ChunkEntries chunk count calculation using ((count-1)/size)+1 formula

- RangeWithSteps now preallocates result slice using math.Ceil for better performance
- Fix edge cases for floating point values with small steps
- Add test cases for float and custom type validation
- Rename TestRangeClose → TestRangeWithSteps for consistency
- Simplify ChunkEntries chunk count calculation using ((count-1)/size)+1 formula
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.19%. Comparing base (c1d11cb) to head (f84106a).
⚠️ Report is 9 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #820      +/-   ##
==========================================
- Coverage   92.28%   92.19%   -0.10%     
==========================================
  Files          32       32              
  Lines        4279     4277       -2     
==========================================
- Hits         3949     3943       -6     
- Misses        249      251       +2     
- Partials       81       83       +2     
Flag Coverage Δ
unittests 92.19% <100.00%> (-0.10%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samber samber merged commit b0b5cc3 into samber:master Feb 25, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants