When optimizing code I regularly come to the following conclusion:
Dim ub As Integer = CalculateUpperBoundMethod()
For i As Integer = 0 To ub
is slower than
For i As Integer = 0 To CalculateUpperBoundMethod()
This didn’t use to be that way with earlier versions (pre 2015 or so). Is this due to the LLVM compiler?
Another thing which seems to have changed is calling a method to get the array for a For…Each loop at the top of the loop:
Dim mis() As Xojo.Core.MethodInfo = ti.MethodInfo()
For Each mi As Xojo.Core.MethodInfo In mis
is slower than
For Each mi As Xojo.Core.MethodInfo In ti.MethodInfo()
Does the parser or the LLVM compiler optimize this by recognizing that the array doesn’t change within the loop and therefore ti.MethodInfo() needs to get called only once?