So a while back, I started preferring this old-school inventory loop form:
for(object obj = first_inventory(whatever); obj; obj = next_inventory(env))
over the modern
foreach(object obj : all_inventory(whatever))
because, eyeballing it, I thought that the former would be faster because next_inventory() is a simple linked-list next-item link, doing a foreach() on all_inventory() makes the driver build a temporary array that it's just going to throw out, and so on.
For whatever reason, I just got around to actually testing this out, and discovered that the foreach() is about 17% faster. Why, I can't imagine, but that's how it is.
Moral of the story: don't think, profile.