Auto merge of #113106 - marcospb19:improve-path-with-extension-function, r=thomcc

std: remove an allocation in `Path::with_extension`

`Path::with_extension` used to reallocate (and copy) paths twice per call, now it does it once, by checking the size of the previous and new extensions it's possible to call `PathBuf::with_capacity` and pass the exact capacity required.

This also reduces the memory consumption of the path returned from `Path::with_extension` by using exact capacity instead of using amortized exponential growth.
This commit is contained in:
bors 2023-07-21 03:47:29 +00:00
commit ddb7a1a528

Diff content is not available