[PyTorch] Improve StorageImpl::set_data_ptr (#65432)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/65432
There is no reason to do an extra write to the input DataPtr (via `std::swap`) before returning a new DataPtr.
ghstack-source-id: 146471376
Test Plan:
Inspected assembly for this function to verify that we are
really getting fewer instructions generated. I don't have a specific
application for this at the moment, but it's clearly better IMO.
Reviewed By: mikeiovine
Differential Revision: D31097807
fbshipit-source-id: 06ff6f5fc675df0f38b0315b4147ed959243b6d0