Fix windows build failure.

C89 code is preferable to gcc code; define variables at the start of
blocks.
Performance optimisation with pdf_cache_object/pdf_get_xref_entry

The recent change to holding pdf xrefs in a sparse format has resulted
in a significant decrease in speed (x10). Malc points out that some of
this (2x) can be recovered simply by making pdf_cache_object return the
entry which it found the object in.

This saves us having to immediately call pdf_get_xref_entry again
afterwards.

I am still thinking about ways to try and get the remaining time back.
Remove unnecessary test.

We know i >= 0 as we've already thrown if i < 0 earlier.

Credit to Malc for spotting this.