Skip to content

Commit d08daec

Browse files
committed
Merge branch 'rs/trace2-dots'
Code cleanup. * rs/trace2-dots: trace2: add dots directly to strbuf in perf_fmt_prepare()
2 parents fc7b26c + 5c34d2f commit d08daec

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

trace2/tr2_tgt_perf.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,9 @@ static int tr2env_perf_be_brief;
2626
#define TR2FMT_PERF_REPO_WIDTH (3)
2727
#define TR2FMT_PERF_CATEGORY_WIDTH (12)
2828

29-
#define TR2_DOTS_BUFFER_SIZE (100)
3029
#define TR2_INDENT (2)
3130
#define TR2_INDENT_LENGTH(ctx) (((ctx)->nr_open_regions - 1) * TR2_INDENT)
3231

33-
static struct strbuf dots = STRBUF_INIT;
34-
3532
static int fn_init(void)
3633
{
3734
int want = tr2_dst_trace_want(&tr2dst_perf);
@@ -41,8 +38,6 @@ static int fn_init(void)
4138
if (!want)
4239
return want;
4340

44-
strbuf_addchars(&dots, '.', TR2_DOTS_BUFFER_SIZE);
45-
4641
brief = tr2_sysenv_get(TR2_SYSENV_PERF_BRIEF);
4742
if (brief && *brief &&
4843
((want_brief = git_parse_maybe_bool(brief)) != -1))
@@ -54,8 +49,6 @@ static int fn_init(void)
5449
static void fn_term(void)
5550
{
5651
tr2_dst_trace_disable(&tr2dst_perf);
57-
58-
strbuf_release(&dots);
5952
}
6053

6154
/*
@@ -138,14 +131,8 @@ static void perf_fmt_prepare(const char *event_name,
138131
strbuf_addf(buf, "%-*.*s | ", TR2FMT_PERF_CATEGORY_WIDTH,
139132
TR2FMT_PERF_CATEGORY_WIDTH, (category ? category : ""));
140133

141-
if (ctx->nr_open_regions > 0) {
142-
int len_indent = TR2_INDENT_LENGTH(ctx);
143-
while (len_indent > dots.len) {
144-
strbuf_addbuf(buf, &dots);
145-
len_indent -= dots.len;
146-
}
147-
strbuf_addf(buf, "%.*s", len_indent, dots.buf);
148-
}
134+
if (ctx->nr_open_regions > 0)
135+
strbuf_addchars(buf, '.', TR2_INDENT_LENGTH(ctx));
149136
}
150137

151138
static void perf_io_write_fl(const char *file, int line, const char *event_name,

0 commit comments

Comments
 (0)