Re: [PATCH v14 21/27] bisect--helper: `bisect_log` shell function in C

2 messages, 2 authors, 2016-08-27 · open the first message on its own page

Re: [PATCH v14 21/27] bisect--helper: `bisect_log` shell function in C

From: Junio C Hamano <hidden>
Date: 2016-08-26 23:07:17

Pranit Bauva [off-list ref] writes:
+static int bisect_log(void)
+{
+	struct strbuf buf = STRBUF_INIT;
+
+	if (strbuf_read_file(&buf, git_path_bisect_log(), 256) < 0) {
+		strbuf_release(&buf);
+		return error(_("We are not bisecting.\n"));
+	}
+
+	printf("%s", buf.buf);
+	strbuf_release(&buf);
+
+	return 0;
+}
Hmph, is it really necessary to slurp everything in a strbuf before
sending it out to the standard output?  Wouldn't it be sufficient to
open a file descriptor for reading on the log file and then hand it
over to copy.c::copy_fd()?

Re: [PATCH v14 21/27] bisect--helper: `bisect_log` shell function in C

From: Pranit Bauva <hidden>
Date: 2016-08-27 20:17:21

Hey Junio,

On Sat, Aug 27, 2016 at 4:37 AM, Junio C Hamano [off-list ref] wrote:
Pranit Bauva [off-list ref] writes:
quoted
+static int bisect_log(void)
+{
+     struct strbuf buf = STRBUF_INIT;
+
+     if (strbuf_read_file(&buf, git_path_bisect_log(), 256) < 0) {
+             strbuf_release(&buf);
+             return error(_("We are not bisecting.\n"));
+     }
+
+     printf("%s", buf.buf);
+     strbuf_release(&buf);
+
+     return 0;
+}
Hmph, is it really necessary to slurp everything in a strbuf before
sending it out to the standard output?  Wouldn't it be sufficient to
open a file descriptor for reading on the log file and then hand it
over to copy.c::copy_fd()?
That is actually much better. Thanks!

Regards,
Pranit Bauva
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help