A quantum-logic gate between two optical photons with an efficiency above 40%