Optimize ReadFile allocations

Instead of continuously reallocating the output string, call reserve()
up front to enlarge the string's buffer.

Also use feof() instead of an empty read to detect the end of the file.
This saves a syscall on <64kb files, which is about 5% (200ns) of the
time to read a file on my machine.

For our larger build.ninja files (~550MB), this saves about 500ms, which
is more than half the time spent in this function. (Measured by adding
METRICS_RECORD to this function during manifest_parser_perftest)

For the standard manifest_parser_perftest, this only saves ~20ms out of
~600ms for a full run.

(cherry picked from commit c9b5eaa55231612aeff85385033a792949162228)
 from https://github.com/ninja-build/ninja/pull/1196

Test: Local builds, benchmarks
Change-Id: I2d7f207fc42b7860d5bc049325ebc91c4a2e0ed8
1 file changed