On Fri, 2008-07-25 at 00:55 +1000, Adelle Hartley wrote: > if (SelectedCustomer.HasValue && SelectedCustomer.Country.HasValue && > SelectedCustomer.Country.Currency.HasValue && > SelectedCustomer.Country.Currency.ExchangeRate.HasValue) > { > // ... Do something with SelectedCustomer.Country.Currency.ExchangeRate > } >
Now this IS a place where optimisation is possible. I reduced 25% runtime of a program to almost zero by getting rid of multiple dereferences like this. It was a data rip of a page and everything was stored in struct which contained arrays containing more structs. I cached a couple of the dereferences at the top and the whole subroutine dropped off the profiler. I had a huge gain I was not expecting. This is why we profile rather than blindly changing things, if it made things worse then I would have unwound the change. Ken _______________________________________________ coders mailing list coders@slug.org.au http://lists.slug.org.au/listinfo/coders