git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] use strbuf_addstr() instead of strbuf_addf() with "%s"
@ 2016-08-05 20:37 René Scharfe
  2016-08-07  8:49 ` Johannes Schindelin
  0 siblings, 1 reply; 2+ messages in thread
From: René Scharfe @ 2016-08-05 20:37 UTC (permalink / raw)
  To: Git List; +Cc: Junio C Hamano

Call strbuf_addstr() for adding a simple string to a strbuf instead of
using the heavier strbuf_addf().  This is shorter and documents the
intent more clearly.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 builtin/fmt-merge-msg.c | 2 +-
 http.c                  | 2 +-
 sequencer.c             | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/builtin/fmt-merge-msg.c b/builtin/fmt-merge-msg.c
index e5658c3..ac84e99 100644
--- a/builtin/fmt-merge-msg.c
+++ b/builtin/fmt-merge-msg.c
@@ -272,7 +272,7 @@ static int cmp_string_list_util_as_integral(const void *a_, const void *b_)
 static void add_people_count(struct strbuf *out, struct string_list *people)
 {
 	if (people->nr == 1)
-		strbuf_addf(out, "%s", people->items[0].string);
+		strbuf_addstr(out, people->items[0].string);
 	else if (people->nr == 2)
 		strbuf_addf(out, "%s (%d) and %s (%d)",
 			    people->items[0].string,
diff --git a/http.c b/http.c
index e81dd13..cd40b01 100644
--- a/http.c
+++ b/http.c
@@ -1225,7 +1225,7 @@ void append_remote_object_url(struct strbuf *buf, const char *url,
 
 	strbuf_addf(buf, "objects/%.*s/", 2, hex);
 	if (!only_two_digit_prefix)
-		strbuf_addf(buf, "%s", hex+2);
+		strbuf_addstr(buf, hex + 2);
 }
 
 char *get_remote_object_url(const char *url, const char *hex,
diff --git a/sequencer.c b/sequencer.c
index cdfac82..7b1eb14 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -112,7 +112,7 @@ static void remove_sequencer_state(void)
 {
 	struct strbuf seq_dir = STRBUF_INIT;
 
-	strbuf_addf(&seq_dir, "%s", git_path(SEQ_DIR));
+	strbuf_addstr(&seq_dir, git_path(SEQ_DIR));
 	remove_dir_recursively(&seq_dir, 0);
 	strbuf_release(&seq_dir);
 }
-- 
2.9.2


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

* Re: [PATCH] use strbuf_addstr() instead of strbuf_addf() with "%s"
  2016-08-05 20:37 [PATCH] use strbuf_addstr() instead of strbuf_addf() with "%s" René Scharfe
@ 2016-08-07  8:49 ` Johannes Schindelin
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Schindelin @ 2016-08-07  8:49 UTC (permalink / raw)
  To: René Scharfe; +Cc: Git List, Junio C Hamano

[-- Attachment #1: Type: text/plain, Size: 273 bytes --]

Hi René,

On Fri, 5 Aug 2016, René Scharfe wrote:

> Call strbuf_addstr() for adding a simple string to a strbuf instead of
> using the heavier strbuf_addf().  This is shorter and documents the
> intent more clearly.

Looks obviously good, thanks!

Ciao,
Dscho

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

end of thread, other threads:[~2016-08-07  8:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-05 20:37 [PATCH] use strbuf_addstr() instead of strbuf_addf() with "%s" René Scharfe
2016-08-07  8:49 ` Johannes Schindelin

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 NNTP newsgroup(s).