Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Thanks, looking back it's most probably too clever. Negative detection could simply be xneg = (x < 0); more readable and code generation would be same or better because it wouldn't confuse optimizers about the intent.
You're welcome :D
But it's optimization theater, really. Most compilers optimize simple ?: expressions to branchless. I wrote it this way bc I was bored.
meh, tabs vs. spaces strike again..
Don't think so. Why would it?
Just checked on Godbolt for GCC x86 and Clang Arm64, -O3 and they don't.
Even if they did, it still would be bad practice, there's no reason to add such cost in debug mode.
Besides, copy-pasting strlen(str) 3 times instead of putting it in one variable looks awful.
Call strlen for each iteration? How is this best practices??
It runs the same as n%2 because compilers turn it into a bit test, it only runs faster with optimizer turned off. I used it because once you're familiar with bit ops, it becomes a self-explanatory idiom.
I accidentally left a printf; ignore this solution and look for my other one.
Yeah, well it's there because I wanted the whole upper 64 part of the ascii table in the map for a simpler masking condition. Although I don't know whether masking improves any performance over just (*s >= *map).
Yes, if returning a static label. It points to program data segment.
Any sane reason why use 32 instead of a char literal ' '?
It'll fail on platforms where strings can be placed in low memory. Besides it's slow: chooses overload at runtime instead of compile-time.
Very elegant
Yeah, how returning pointer to stack got top score in best practices is beyond me...
Should return an int, not pointer.
Loading more items...