Replace calls to strbuf_init(&foo, 0) with STRBUF_INIT initializer
Many call sites use strbuf_init(&foo, 0) to initialize local strbuf variable "foo" which has not been accessed since its declaration. These can be replaced with a static initialization using the STRBUF_INIT macro which is just as readable, saves a function call, and takes up fewer lines. Signed-off-by: Brandon Casey <casey@nrlssc.navy.mil> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:

committed by
Shawn O. Pearce

parent
7e7abea96b
commit
f285a2d7ed
13
graph.c
13
graph.c
@ -1010,14 +1010,12 @@ int graph_is_commit_finished(struct git_graph const *graph)
|
||||
|
||||
void graph_show_commit(struct git_graph *graph)
|
||||
{
|
||||
struct strbuf msgbuf;
|
||||
struct strbuf msgbuf = STRBUF_INIT;
|
||||
int shown_commit_line = 0;
|
||||
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
strbuf_init(&msgbuf, 0);
|
||||
|
||||
while (!shown_commit_line) {
|
||||
shown_commit_line = graph_next_line(graph, &msgbuf);
|
||||
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
|
||||
@ -1031,12 +1029,11 @@ void graph_show_commit(struct git_graph *graph)
|
||||
|
||||
void graph_show_oneline(struct git_graph *graph)
|
||||
{
|
||||
struct strbuf msgbuf;
|
||||
struct strbuf msgbuf = STRBUF_INIT;
|
||||
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
strbuf_init(&msgbuf, 0);
|
||||
graph_next_line(graph, &msgbuf);
|
||||
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
|
||||
strbuf_release(&msgbuf);
|
||||
@ -1044,12 +1041,11 @@ void graph_show_oneline(struct git_graph *graph)
|
||||
|
||||
void graph_show_padding(struct git_graph *graph)
|
||||
{
|
||||
struct strbuf msgbuf;
|
||||
struct strbuf msgbuf = STRBUF_INIT;
|
||||
|
||||
if (!graph)
|
||||
return;
|
||||
|
||||
strbuf_init(&msgbuf, 0);
|
||||
graph_padding_line(graph, &msgbuf);
|
||||
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
|
||||
strbuf_release(&msgbuf);
|
||||
@ -1057,7 +1053,7 @@ void graph_show_padding(struct git_graph *graph)
|
||||
|
||||
int graph_show_remainder(struct git_graph *graph)
|
||||
{
|
||||
struct strbuf msgbuf;
|
||||
struct strbuf msgbuf = STRBUF_INIT;
|
||||
int shown = 0;
|
||||
|
||||
if (!graph)
|
||||
@ -1066,7 +1062,6 @@ int graph_show_remainder(struct git_graph *graph)
|
||||
if (graph_is_commit_finished(graph))
|
||||
return 0;
|
||||
|
||||
strbuf_init(&msgbuf, 0);
|
||||
for (;;) {
|
||||
graph_next_line(graph, &msgbuf);
|
||||
fwrite(msgbuf.buf, sizeof(char), msgbuf.len, stdout);
|
||||
|
Reference in New Issue
Block a user