3 ms·
The budget for doing optimizations is always limited and while I don't know how common this technique is in C, optimizing for poorly written code is in general
by bad_user 11y ago
The budget for doing optimizations is always limited and while I don't know how common this technique is in C, optimizing for poorly written code is in general a losing battle that waists the optimization budget.
- simias 11y agoThis thread is the first time I hear people say that the bangbang boolean cast "operator" is poor coding. It's very idiomatic in my experience and it doesn't give me pause at all. I mean, if it's forbidden by your particular coding style then fair enough but it's a bit harsh to cry at this bit of code because it makes use of it. For what it's worth I made a quick grep for ' !!' in the linux kernel and found 2439 matches. I think it's more a matter of subjective taste than a sign of poor coding. And I maintain that any C compiler worth its salt will handle '!!' just fine, it's a really simple optimization (and even if you consider double-negations poor style in your code it'll crop up quite often while inlining functions or expanding macros for instance).
- nitrogen 11y agoThe double exclamation is fairly common in C, and really, poorly written code probably has the greatest opportunity for optimization.