Optimized key compare