How much of a speed penalty is there when using the reflection library?
For example, which of the following two methods is faster, and by how much? Is it negligible and doesn't make a difference, or is one method much better than the other?
Finding the correct View using reflection:
Finding the correct View by iterating through all Views:
The "For Counter = 0 To 1000" loop is just there to magnify the speed difference. The real code will not have this.
For example, which of the following two methods is faster, and by how much? Is it negligible and doesn't make a difference, or is one method much better than the other?
Finding the correct View using reflection:
B4X:
Dim refView As Reflector
Dim v As View
'Views have previously been assigned Tags
refView.Target = Activity
For Counter = 0 To 1000
v = refView.RunMethod2("FindViewWithTag", Counter, "lang.java.int")
v.Width = 100dip
Next
Finding the correct View by iterating through all Views:
B4X:
Dim v As View
'Views have previously been assigned Tags
For Counter = 0 To 1000
For Each v As View In Activity.GetAllViewsRecursive
If v.Tag = Counter
v.Width = 100dip
Exit
End If
Next
Next