git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH] use strbuf_addstr() for adding constant strings to a strbuf
@ 2016-07-30 17:36 René Scharfe
  2016-08-01 16:49 ` Jeff King
  0 siblings, 1 reply; 3+ messages in thread
From: René Scharfe @ 2016-07-30 17:36 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Replace uses of strbuf_addf() for adding strings with more lightweight
strbuf_addstr() calls.

In http-push.c it becomes easier to see what's going on without having
to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain
any format specifiers.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/rev-parse.c         | 2 +-
 http-push.c                 | 2 +-
 send-pack.c                 | 2 +-
 t/helper/test-run-command.c | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/rev-parse.c b/builtin/rev-parse.c
index c961b74..76cf05e 100644
--- a/builtin/rev-parse.c
+++ b/builtin/rev-parse.c
@@ -469,7 +469,7 @@ static int cmd_parseopt(int argc, const char **argv, const char *prefix)
 			(stop_at_non_option ? PARSE_OPT_STOP_AT_NON_OPTION : 0) |
 			PARSE_OPT_SHELL_EVAL);
 
-	strbuf_addf(&parsed, " --");
+	strbuf_addstr(&parsed, " --");
 	sq_quote_argv(&parsed, argv, 0);
 	puts(parsed.buf);
 	return 0;
diff --git a/http-push.c b/http-push.c
index a092f02..d0b29ac 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1137,7 +1137,7 @@ static void remote_ls(const char *path, int flags,
 	ls.userData = userData;
 	ls.userFunc = userFunc;
 
-	strbuf_addf(&out_buffer.buf, PROPFIND_ALL_REQUEST);
+	strbuf_addstr(&out_buffer.buf, PROPFIND_ALL_REQUEST);
 
 	dav_headers = curl_slist_append(dav_headers, "Depth: 1");
 	dav_headers = curl_slist_append(dav_headers, "Content-Type: text/xml");
diff --git a/send-pack.c b/send-pack.c
index 299d303..1f85c56 100644
--- a/send-pack.c
+++ b/send-pack.c
@@ -265,7 +265,7 @@ static int generate_push_cert(struct strbuf *req_buf,
 	struct strbuf cert = STRBUF_INIT;
 	int update_seen = 0;
 
-	strbuf_addf(&cert, "certificate version 0.1\n");
+	strbuf_addstr(&cert, "certificate version 0.1\n");
 	strbuf_addf(&cert, "pusher %s ", signing_key);
 	datestamp(&cert);
 	strbuf_addch(&cert, '\n');
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 30a64a9..6bb53da 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -26,7 +26,7 @@ static int parallel_next(struct child_process *cp,
 		return 0;
 
 	argv_array_pushv(&cp->args, d->argv);
-	strbuf_addf(err, "preloaded output of a child\n");
+	strbuf_addstr(err, "preloaded output of a child\n");
 	number_callbacks++;
 	return 1;
 }
@@ -36,7 +36,7 @@ static int no_job(struct child_process *cp,
 		  void *cb,
 		  void **task_cb)
 {
-	strbuf_addf(err, "no further jobs available\n");
+	strbuf_addstr(err, "no further jobs available\n");
 	return 0;
 }
 
@@ -45,7 +45,7 @@ static int task_finished(int result,
 			 void *pp_cb,
 			 void *pp_task_cb)
 {
-	strbuf_addf(err, "asking for a quick stop\n");
+	strbuf_addstr(err, "asking for a quick stop\n");
 	return 1;
 }
 
-- 
2.9.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf
  2016-07-30 17:36 [PATCH] use strbuf_addstr() for adding constant strings to a strbuf René Scharfe
@ 2016-08-01 16:49 ` Jeff King
  2016-08-01 20:41   ` Junio C Hamano
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2016-08-01 16:49 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git List, Junio C Hamano

On Sat, Jul 30, 2016 at 07:36:23PM +0200, René Scharfe wrote:

> Replace uses of strbuf_addf() for adding strings with more lightweight
> strbuf_addstr() calls.
> 
> In http-push.c it becomes easier to see what's going on without having
> to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain
> any format specifiers.

Nice. I care a lot less about whether "addf" or "addstr" is more
efficient. But the second point, that it makes the intent clearer, is a
big win.

-Peff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] use strbuf_addstr() for adding constant strings to a strbuf
  2016-08-01 16:49 ` Jeff King
@ 2016-08-01 20:41   ` Junio C Hamano
  0 siblings, 0 replies; 3+ messages in thread
From: Junio C Hamano @ 2016-08-01 20:41 UTC (permalink / raw)
  To: Jeff King; +Cc: René Scharfe, Git List

Jeff King <peff@peff.net> writes:

> On Sat, Jul 30, 2016 at 07:36:23PM +0200, René Scharfe wrote:
>
>> Replace uses of strbuf_addf() for adding strings with more lightweight
>> strbuf_addstr() calls.
>> 
>> In http-push.c it becomes easier to see what's going on without having
>> to verfiy that the definition of PROPFIND_ALL_REQUEST doesn't contain
>> any format specifiers.
>
> Nice. I care a lot less about whether "addf" or "addstr" is more
> efficient. But the second point, that it makes the intent clearer, is a
> big win.

Yes!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-08-01 20:41 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-30 17:36 [PATCH] use strbuf_addstr() for adding constant strings to a strbuf René Scharfe
2016-08-01 16:49 ` Jeff King
2016-08-01 20:41   ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).