diff options
author | Jim Hill <gjthill@gmail.com> | 2015-05-31 11:16:45 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-08-10 12:51:13 -0700 |
commit | 3ebbd00cf3c5a7c6f90e2fed8adaf0c5145fb4ac (patch) | |
tree | 128975e73a85e64cc9ddb6db9896b7e5ec94d575 /Makefile | |
parent | Merge branch 'maint-1.9' into maint-2.0 (diff) | |
download | tgif-3ebbd00cf3c5a7c6f90e2fed8adaf0c5145fb4ac.tar.xz |
strbuf_read(): skip unnecessary strbuf_grow() at eof
The loop in strbuf_read() uses xread() repeatedly while extending
the strbuf until the call returns zero. If the buffer is
sufficiently large to begin with, this results in xread()
returning the remainder of the file to the end (returning
non-zero), the loop extending the strbuf, and then making another
call to xread() to have it return zero.
By using read_in_full(), we can tell when the read reached the end
of file: when it returns less than was requested, it's eof. This
way we can avoid an extra iteration that allocates an extra 8kB
that is never used.
Signed-off-by: Jim Hill <gjthill@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Makefile')
0 files changed, 0 insertions, 0 deletions