[PATCH v2 03/19] fast-import: simplify via strbuf_set()
- From
Jeremiah Mahler <jmmahler@gmail.com>
- Date
- Jun 9, 2014, 22:19 UTC
- Message-ID
- <3c2074297916c6f5f8deb923432af22edd1dccd2.1402348696.git.jmmahler@gmail.com>
- In-Reply-To
- <cover.1402348696.git.jmmahler@gmail.com>
Simplify cases where a strbuf_reset is immediately followed by a strbuf_add by using strbuf_set operations.
Signed-off-by: Jeremiah Mahler <jmmahler@gmail.com> --- fast-import.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fast-import.c b/fast-import.c index e8ec34d..cfe9404 100644 --- a/fast-import.c +++ b/fast-import.c @@ -2898,8 +2898,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20]) * Output based on batch_one_object() from cat-file.c. */ if (type <= 0) { - strbuf_reset(&line); - strbuf_addf(&line, "%s missing\n", sha1_to_hex(sha1)); + strbuf_setf(&line, "%s missing\n", sha1_to_hex(sha1)); cat_blob_write(line.buf, line.len); strbuf_release(&line); free(buf); @@ -2910,8 +2909,7 @@ static void cat_blob(struct object_entry *oe, unsigned char sha1[20]) if (type != OBJ_BLOB) die("Object %s is a %s but a blob was expected.", sha1_to_hex(sha1), typename(type)); - strbuf_reset(&line); - strbuf_addf(&line, "%s %s %lu\n", sha1_to_hex(sha1), + strbuf_setf(&line, "%s %s %lu\n", sha1_to_hex(sha1), typename(type), size); cat_blob_write(line.buf, line.len); strbuf_release(&line);
-- 2.0.0.592.gf55b190