say i have an auto property Public Property P As Integer and everytime I want to read this variable P in a function, i will declare a local variable as such: dim _p = P then read _p instead of P.
I’m wondering does it make sense at all? will it actually make things slower (which of course isn’t my intention)
Btw if we change the question to Public Property P As Object is there any change in the answer?
If you access
Me.P(or_p) several hundred thousand times in the method, copying the property to a local variable will speed things up. However, for most cases, this isn’t a concern, so you can do whichever, and it won’t make a noticeable difference.I’m generally in favor of making code easier to understand, so I’d favor accessing the property, unless you find that you need the additional performance.
Me.Pis easier to understand than_pis.