]> git.ipfire.org Git - thirdparty/git.git/commitdiff
trace2: trim_trailing_newline followed by trim is a no-op
authorJunio C Hamano <gitster@pobox.com>
Thu, 31 Jul 2025 22:54:32 +0000 (15:54 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 3 Aug 2025 05:44:58 +0000 (22:44 -0700)
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 <gitster@pobox.com>
trace2/tr2_cfg.c

index 22a99a0682a4985d43cfb2bc4ae26c8954e09de4..2b7cfcd10c70ea442ed5bd06772e71cfbc93b2f4 100644 (file)
@@ -39,7 +39,6 @@ static int tr2_cfg_load_patterns(void)
 
                if (buf->len && buf->buf[buf->len - 1] == ',')
                        strbuf_setlen(buf, buf->len - 1);
-               strbuf_trim_trailing_newline(*s);
                strbuf_trim(*s);
        }
 
@@ -78,7 +77,6 @@ static int tr2_load_env_vars(void)
 
                if (buf->len && buf->buf[buf->len - 1] == ',')
                        strbuf_setlen(buf, buf->len - 1);
-               strbuf_trim_trailing_newline(*s);
                strbuf_trim(*s);
        }