Skip to content

perf: avoid extra array copies in xy median and scan helpers#385

Merged
lpatiny merged 1 commit into
mainfrom
review-xy-median-improvements
Jul 9, 2026
Merged

perf: avoid extra array copies in xy median and scan helpers#385
lpatiny merged 1 commit into
mainfrom
review-xy-median-improvements

Conversation

@lpatiny

@lpatiny lpatiny commented Jul 9, 2026

Copy link
Copy Markdown
Member

Follow-up cleanups from reviewing the xy folder.

  • xMedian: add optional fromIndex/toIndex range so it slices only the needed window internally (backward compatible).
  • xyMedianY / xyMedianYAtXs: pass the range to xMedian instead of building a per-point window — removes the double copy for plain-array input and drops the ArrayBuffer.isView branch.
  • xyAlign: compute the weighted x only for the 'weighted' option.
  • xyMaxY / xyMaxYPoint / xyMinYPoint: start the scan one index after the seed value.
  • xyMedian: guard the exact-half branch against an out-of-bounds read at the last index.

- xMedian: add optional fromIndex/toIndex range so it slices only the
  needed window internally
- xyMedianY / xyMedianYAtXs: pass the range to xMedian instead of building
  a per-point window (removes the double copy for plain-array input)
- xyAlign: compute the weighted x only for the 'weighted' option
- xyMaxY / xyMaxYPoint / xyMinYPoint: start the scan after the seed index
- xyMedian: guard the exact-half branch against an out-of-bounds read at
  the last index
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.16%. Comparing base (9fed281) to head (88be187).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
+ Coverage   97.13%   97.16%   +0.03%     
==========================================
  Files         207      208       +1     
  Lines        4147     4161      +14     
  Branches     1036     1033       -3     
==========================================
+ Hits         4028     4043      +15     
+ Misses        115      114       -1     
  Partials        4        4              

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lpatiny lpatiny merged commit b068dcb into main Jul 9, 2026
10 checks passed
@lpatiny lpatiny deleted the review-xy-median-improvements branch July 9, 2026 05:38
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.

1 participant