johnatm / itween

Automatically exported from code.google.com/p/itween
1 stars 2 forks source link

Non-trivial code which has no effect #79

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
While going through your code I noticed a lot maths which does nothing. Things 
like "value /= 1;", I'm not sure why they're in there, but that stuff won't 
matter in the long run, it should end up compiled out.

I did however, find some instances of more complex code which does nothing, 
take for example this line in punch():

s = period / (2 * Mathf.PI) * Mathf.Asin(0);

By my understanding, asin(0) is always 0, so this whole line will always end up 
zero, but I'm not sure that the compiler will be smart enough to know that. 
Hence it may actually waste cycles computing it every call.

It's not major, but I thought I'd give you a heads up on it.

Original issue reported on code.google.com by FHR...@gmail.com on 14 Jul 2011 at 6:16

GoogleCodeExporter commented 8 years ago
There's another in easeInElastic(): a is set to 0, then it's compared against 0 
in an if statement without being changed in between, so the comparison is 
always true. That means there's no use for the else statement afterwards, nor 
for the trailing "a < Mathf.Abs(end)" in the if statement because eager 
evaluation will mean that's never evaluated.

In fact I think the else statement has a divide by zero in that case anyway 
"Mathf.Asin(1 / a)", so it's probably compiled out early. I'm surprised it 
doesn't bail on errors, or maybe I'm missing something... ;-)

Original comment by FHR...@gmail.com on 14 Jul 2011 at 6:30