The \Magento\Customer\Model\Attribute::afterSave() method does the same action for both conditions and so can be simplified

This can be simplified to:

if ($this->isObjectNew() && (bool)$this->getData(EavAttributeInterface::IS_USED_IN_GRID)
	|| !$this->isObjectNew() && $this->dataHasChangedFor(EavAttributeInterface::IS_USED_IN_GRID)
) {
	$this->_getResource()->addCommitCallback([$this, 'invalidate']);
}