Hash function to avoid funcalls if possible