swift icon indicating copy to clipboard operation
swift copied to clipboard

[stdlib] performance optimizations in `Array.replaceSubrange`

Open oxy opened this issue 1 year ago • 15 comments

This PR is intended to generally improve performance for replaceSubrange.

Currently, it simplifies the main codepath to avoid unneeded branches. Additional plans:

  • [ ] write benchmarks for replaceSubrange in a variety of contexts (replacing 1 element, 10%, 50%, and 100%, and growing/shrinking)
  • [ ] add an additional branch for replaceSubrange that doesn't modify an existing Array in place and instead constructs a new Array with copy/move (for non-unique / growth cases)

oxy avatar May 26 '23 00:05 oxy