_revertWithReasonIfOneIsReturned implements a memory cost calculation logic. This is duplicated in four places: _performERC20Transfer, _performERC721Transfer, _performERC1155Transfer, _performERC1155BatchTransfer.
Several slight issues were identified with this function and those may or may not be present in five places in total.
Context: LowLevelHelper.sol#L46, TokenTransferrer.sol#L79, TokenTransferrer.sol#L259, TokenTransferrer.sol#L393, TokenTransferrer.sol#L639
Reduce code duplication and risk of differences between them.
