3 ms·
It depends on whether The Compiler is Smart Enough™ — verbose code, for example, declares variables for values before using them in expressions. So instead of
by adimitrov 10y ago
It depends on whether The Compiler is Smart Enough™ — verbose code, for example, declares variables for values before using them in expressions.
So instead of
if (long.and(Complex(Expression)) && (other || long && expressions)
You use
mandatoryConditional = long.and(Complex(Expression))
optionalConditional = other
otherOptional = complex && expressions
if (mandatoryConditional && (optionalConditional || otherOptional)
Now you have more names hanging around, and longer code, but it's better to read, especially if these conditional variables are named properly. Some people fear that this could negatively impact execution time, but I don't think it will have any noticable impact in modern languages.
Another problem could occur where people verbosely allocate things, pre-computing and re-computing aggregate data structures, and a one-liner would've been more efficient since it goes over the same data only once.