3 ms·
Do you have an example of when == would be faster than a comparison? I can't think of any case that would have any appreciable difference in speed. Is it most
by cogman10 7y ago
Do you have an example of when == would be faster than a comparison?
I can't think of any case that would have any appreciable difference in speed.
Is it mostly around eliminating branching logic?
Wouldn't there be a good chance that might be inlined and optimized away anyways?
- johannes1234321 7y agoOn case is string comparison. When implementing == I can shortcut if length doesn't matter the string can't be equal. When implementing <=> I however have to iterate in any case. (While there the question then is if the shortcut is really efficient, as the iteration might already stop on first character ...)