Why does ERC721 use assembly to revert in _checkOnERC721Received?

 if (reason.length == 0) {
     revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
      assembly {
          revert(add(32, reason), mload(reason))
      }
}

If the reason length is non-zero, why is assembly used here? And what does that revert do?

1 Like

Reverting with a custom reason if reason.length != 0