I've read several articles and questions/answers that conclude the best practice is to let the JIT compiler do all the optimization for inline function calls. Makes sense.
What about inline variable declarations? Does the compiler optimize these as well?
That is, will this:
Dim h = (a + b + c) / 2 'Half-Perimeter
If maxEdgeLength / (Math.Sqrt(h * (h - a) * (h - b) * (h - c)) / h) <= MaximumTriangleAspectRatio Then
'Do stuff here.
End If
Have better performance than this:
Dim perimeter = a + b + c 'Perimeter
Dim h = perimeter / 2 'Half-Perimeter
Dim area = Math.Sqrt(h * (h - a) * (h - b) * (h - c)) 'Heron's forumula.
Dim inradius = area / h
Dim aspectRatio = maxEdgeLength / inradius
If aspectRatio <= MaximumTriangleAspectRatio Then
'Do stuff here.
End If
Of course I prefer the latter because it's easier to read and debug, but I can't afford the performance degradation if it exists.
Note: I have already identified this code as a bottleneck -- No need for retorts about premature optimization. :-)