aboutsummaryrefslogtreecommitdiff
path: root/strbuf.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-11 14:23:42 -0700
committerJunio C Hamano <gitster@pobox.com>2015-05-11 14:23:42 -0700
commit6cc983d0adc9fca975d977b4432c4645db9de464 (patch)
treeeb4c7e9af146935175ce09f0568a9a6b31b5a331 /strbuf.h
parent66ff763ebb35e5fc379f73c2769656cd61fe6b33 (diff)
parenta33729267504c7b1a63a1f05b47faea6f9e1642c (diff)
downloadgit-6cc983d0adc9fca975d977b4432c4645db9de464.tar.gz
git-6cc983d0adc9fca975d977b4432c4645db9de464.tar.xz
Merge branch 'jk/reading-packed-refs'
An earlier rewrite to use strbuf_getwholeline() instead of fgets(3) to read packed-refs file revealed that the former is unacceptably inefficient. * jk/reading-packed-refs: t1430: add another refs-escape test read_packed_refs: avoid double-checking sane refs strbuf_getwholeline: use getdelim if it is available strbuf_getwholeline: avoid calling strbuf_grow strbuf_addch: avoid calling strbuf_grow config: use getc_unlocked when reading from file strbuf_getwholeline: use getc_unlocked git-compat-util: add fallbacks for unlocked stdio strbuf_getwholeline: use getc macro
Diffstat (limited to 'strbuf.h')
-rw-r--r--strbuf.h3
1 files changed, 2 insertions, 1 deletions
diff --git a/strbuf.h b/strbuf.h
index 1883494ca..01c5c6371 100644
--- a/strbuf.h
+++ b/strbuf.h
@@ -205,7 +205,8 @@ extern int strbuf_cmp(const struct strbuf *, const struct strbuf *);
*/
static inline void strbuf_addch(struct strbuf *sb, int c)
{
- strbuf_grow(sb, 1);
+ if (!strbuf_avail(sb))
+ strbuf_grow(sb, 1);
sb->buf[sb->len++] = c;
sb->buf[sb->len] = '\0';
}