top | item 39827488

(no title)

hardware2win | 1 year ago

Leave code without obvious side effects alone (this is different from dead code)

discuss

order

dzaima|1 year ago

What would "leave alone" even be? There's no "default" state of performance of Java code; it would be ridiculously stupid for there to be something saying that, say, "a+b" for int type values has to take at least 1 nanosecond or something. And you can't use big O complexity here either - the int type has a maximum of 2 billion, and thus a loop over it is trivially O(1), just with a potentially-big constant factor. (or, alternatively, the loop was sped up by a constant factor of 2 billion, and optimizing compilers should extremely obviously be allowed to optimize code by a constant factor)

thfuran|1 year ago

But this is code obviously without side effect.

hardware2win|1 year ago

There are side effects, but in real world, not abstract