Reduce some database access on diff pages by using select_related() and avoiding reloading objects by ID when they've already been loaded.
Review Request #1929 — Created Nov. 16, 2010 and submitted
Reduce some database access on diff pages by using select_related() and avoiding reloading objects by ID when they've already been loaded. select_related is the same as the changes from http://reviews.reviewboard.org/r/1895/ - it uses joins to reduce round-trips to the database for stuff that'll get loaded anyway. The other change is to just pass full objects instead of IDs to a couple functions so we didn't have to reload the objects again by ID when we had already loaded them at the caller.
Tested out with SQL logging on, confirmed that it produced less round trips. This code is running on our instance.
Looks good. Pushed to master as 902d5f6.