Skip to content

Commit 820dcc2

Browse files
committed
trace2: trim_trailing_newline followed by trim is a no-op
strbuf_trim_trailing_newline() removes a LF or a CRLF from the tail of a string. If the code plans to call strbuf_trim() immediately after doing so, the code is better off skipping the EOL trimming in the first place. After all, LF/CRLF at the end is a mere special case of whitespaces at the end of the string, which will be removed by strbuf_rtrim() anyway. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d099fd commit 820dcc2

File tree

1 file changed

+0
-2
lines changed

1 file changed

+0
-2
lines changed

trace2/tr2_cfg.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ static int tr2_cfg_load_patterns(void)
3939

4040
if (buf->len && buf->buf[buf->len - 1] == ',')
4141
strbuf_setlen(buf, buf->len - 1);
42-
strbuf_trim_trailing_newline(*s);
4342
strbuf_trim(*s);
4443
}
4544

@@ -78,7 +77,6 @@ static int tr2_load_env_vars(void)
7877

7978
if (buf->len && buf->buf[buf->len - 1] == ',')
8079
strbuf_setlen(buf, buf->len - 1);
81-
strbuf_trim_trailing_newline(*s);
8280
strbuf_trim(*s);
8381
}
8482

0 commit comments

Comments
 (0)