StringUtils: Avoid unnecessary allocation in ReplaceAll (#79915)
When the replacement string is smaller than the search string,
`ReplaceAll` can operate in-place on the original string and so
avoid an extra allocation and some string copies.
As suggested in https://github.com/pytorch/pytorch/pull/76976#discussion_r902036461
Pull Request resolved: https://github.com/pytorch/pytorch/pull/79915
Approved by: https://github.com/ezyang