On Sunday, April 29, 2012 10:22:44 David Nadlinger wrote: > On Sunday, 29 April 2012 at 08:20:59 UTC, Jonathan M Davis wrote: > > The compiler doesn't necessarily know that foo won't remove key > > from aa, so it > > can't save the result of key in aa to reuse rather than calling > > aa[key], > > whereas the programmer could know that foo doesn't do anything > > to aa which > > would make a pointer to the element invalid and can guarantee > > that only one > > lookup occurs by doing > > […] > > Yes, point taken, but what does this have to do with locality?
I think that you're thinking of something completely different about the term locality than I meant. I meant locality in terms of how close the aa[key] expression was to the key in aa expression within the function - i.e. how local they were to each other. I may have misused the term though. I don't know. - Jonathan M Davis