sverrirs
Joined 11 years ago
Joined 11 years ago
People will and are arguing that "it is kernel code, it should be complicated" but I really think this is backwards. Because it is low level and debugging is really cognitively intense and difficult at this level the code should be even clearer and easier to understand.
Also, "less skilled devs" are just people that are still learning. We've all been there.
https://en.wikipedia.org/wiki/XOR_swap_algorithm#Reasons_for...
1. Just because things aren't done "the way you would do them" doesn't mean they're "bad" or "wrong".
2. If you're not on a solo project, I've found writing correct but less "clever" code to help shorten ramp-up time for new devs and be more beneficial to future maintainability of the code-base and system.
TL;DR; Swapping values by XOR'ing may look elite and clever but hurts you in the long run.