Skip to content

Commit 413c5ab

Browse files
Seija KijinAZero13
authored andcommitted
git: replace strbuf_addstr with strbuf_addch for all strings of length 2
Adding the char directly instead of a string of length 2 is clearer and more efficient. Signed-off-by: Seija Kijin <[email protected]>
1 parent d882f38 commit 413c5ab

File tree

12 files changed

+12
-12
lines changed

12 files changed

+12
-12
lines changed

bisect.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ static int register_ref(const char *refname, const char *referent UNUSED, const
454454
{
455455
struct strbuf good_prefix = STRBUF_INIT;
456456
strbuf_addstr(&good_prefix, term_good);
457-
strbuf_addstr(&good_prefix, "-");
457+
strbuf_addch(&good_prefix, '-');
458458

459459
if (!strcmp(refname, term_bad)) {
460460
free(current_bad_oid);

builtin/ls-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
3737
} else if (padded) {
3838
strbuf_addf(line, "%7s", "-");
3939
} else {
40-
strbuf_addstr(line, "-");
40+
strbuf_addch(line, '-');
4141
}
4242
}
4343

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ static void trace_encoding(const char *context, const char *path,
337337
((i+1) % 8 && (i+1) < len ? ' ' : '\n')
338338
);
339339
}
340-
strbuf_addchars(&trace, '\n', 1);
340+
strbuf_addch(&trace, '\n');
341341

342342
trace_strbuf(&coe, &trace);
343343
strbuf_release(&trace);

diff.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1763,7 +1763,7 @@ static void add_line_count(struct strbuf *out, int count)
17631763
strbuf_addstr(out, "0,0");
17641764
break;
17651765
case 1:
1766-
strbuf_addstr(out, "1");
1766+
strbuf_addch(out, '1');
17671767
break;
17681768
default:
17691769
strbuf_addf(out, "1,%d", count);

log-tree.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ void fmt_output_subject(struct strbuf *filename,
452452

453453
strbuf_addf(&temp, "v%s", info->reroll_count);
454454
format_sanitized_subject(filename, temp.buf, temp.len);
455-
strbuf_addstr(filename, "-");
455+
strbuf_addch(filename, '-');
456456
strbuf_release(&temp);
457457
}
458458
strbuf_addf(filename, "%04d-%s", nr, subject);

merge-ort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -827,7 +827,7 @@ static void path_msg(struct merge_options *opt,
827827

828828
va_start(ap, fmt);
829829
if (opt->priv->call_depth) {
830-
strbuf_addchars(dest, ' ', 2);
830+
strbuf_addstr(dest, " ");
831831
strbuf_addstr(dest, "From inner merge:");
832832
strbuf_addchars(dest, ' ', opt->priv->call_depth * 2);
833833
}

path.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@ const char *remove_leading_path(const char *in, const char *prefix)
982982

983983
strbuf_reset(&buf);
984984
if (!in[j])
985-
strbuf_addstr(&buf, ".");
985+
strbuf_addch(&buf, '.');
986986
else
987987
strbuf_addstr(&buf, in + j);
988988
return buf.buf;

pretty.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ void pp_user_info(struct pretty_print_context *pp,
590590

591591
strbuf_addf(sb, "%s: ", what);
592592
if (pp->fmt == CMIT_FMT_FULLER)
593-
strbuf_addchars(sb, ' ', 4);
593+
strbuf_addstr(sb, " ");
594594

595595
strbuf_addf(&id, "%.*s <%.*s>", (int)namelen, namebuf,
596596
(int)maillen, mailbuf);

protocol-caps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static void send_info(struct repository *r, struct packet_writer *writer,
6565

6666
if (info->size) {
6767
if (oid_object_info(r, &oid, &object_size) < 0) {
68-
strbuf_addstr(&send_buffer, " ");
68+
strbuf_addch(&send_buffer, ' ');
6969
} else {
7070
strbuf_addf(&send_buffer, " %lu", object_size);
7171
}

send-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ static int generate_push_cert(struct strbuf *req_buf,
373373
if (args->push_options)
374374
for_each_string_list_item(item, args->push_options)
375375
strbuf_addf(&cert, "push-option %s\n", item->string);
376-
strbuf_addstr(&cert, "\n");
376+
strbuf_addch(&cert, '\n');
377377

378378
for (ref = remote_refs; ref; ref = ref->next) {
379379
if (check_to_send_update(ref, args) < 0)

0 commit comments

Comments
 (0)