3 ms·
I'm sorry, how can verbose code impact performance???? Please elaborate.
by knocte 10y ago
I'm sorry, how can verbose code impact performance???? Please elaborate.
- erlehmann_ 10y agoIn shell scripts, for example, accessing a longer variable takes longer time than accessing a shorter variable. In my testing, accessing a 100 character variable took around 20% longer than accessing a 1 character variable.
- adimitrov 10y agoIt 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.