swift
swift copied to clipboard
[stdlib] performance optimizations in `Array.replaceSubrange`
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)