You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. Unless I'm mistaken, the two methods produce different outputs as the b < key results have been flipped.
If we account for this anomaly and introduce a third method that more directly compares the if and match equivalents, both using cmp and Ordering, we see the output is identical.
The difference appears to be due to the use of cmp and Ordering rather than if and match. In the final assembly, if_else makes use of a conditional move which is likely going to be faster.
https://rust.godbolt.org/z/zKEfaPKdn
inspired from https://stackoverflow.com/questions/67412863/match-compiles-into-suboptimal-asm-compared-to-if-else
The text was updated successfully, but these errors were encountered: