News for hackers. Stuff that matters.
Re:Const all the things? by LevelAd8 on Monday January 24, 2022 @03:58AM (#30055026)
2 more instructions in GodBolt for the second version, in the end the urge to look cool and "elite" more often than not causes trouble. Unless there really is a need for complexity, it's almost always better to follow KISS principle
Re:Const all the things? by nkurz on Monday January 24, 2022 @09:24AM (#30057909)
I saw no difference for between unwind's two versions with current GCC, clang, or icc with -O3: https://godbolt.org/z/n6avo5ovq. Did you possibly forgot to use optimization? I was surprised though to see that icc inlined the call to strlen!
Re:Const all the things? by unwind on Monday January 24, 2022 @04:22AM (#30055187)
Okay, thanks.

Obviously using post-decrement in the if like I did is a red flag of readability/complexity in many cases, and I could just have well kept the subtraction to the indexing line.