use strbuf_addstr() instead of strbuf_addf() with "%s"
PATCH 1/1 use strbuf_addstr() instead of strbuf_addf() with "%s"
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 <[email protected]>
--- builtin/fmt-merge-msg.c | 2 +- http.c | 2 +- sequencer.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
builtin/fmt-merge-msg.c +1 -1
@@ -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,
http.c +1 -1
@@ -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,
sequencer.c +1 -1
@@ -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); }
Signature · 1 line
2.9.2
Hi René,
Quoted 3 lines · René Scharfe
Call
strbuf_addstr()for adding a simple string to a strbuf instead of using the heavierstrbuf_addf(). This is shorter and documents the intent more clearly.
Looks obviously good, thanks!
Ciao,
Dscho