Protect writes to lookup with hash check

This will avoid unnecessary writes if the data has not
changed.