strbuf: use _rtrim and _ltrim in strbuf_trim
strbuf_trim() strips whitespace from the end, then the beginning of a strbuf. Those operations are duplicated in strbuf_rtrim() and strbuf_ltrim(). Replace strbuf_trim() implementation with calls to strbuf_rtrim(), then strbuf_ltrim(). Signed-off-by: Brian Gesiak <modocache@gmail.com> Reviewed-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brian Gesiak committed
Apr 30, 2014 at 17:58 UTC
3bb55e8aa86f054c081c372b227f723e3aad14c7
1 file changed
+2
-9
strbuf.c
+2
-9
@@ -78,15 +78,8 @@ void strbuf_grow(struct strbuf *sb, size_t extra)
78
79
void strbuf_trim(struct strbuf *sb)
80
{
81
- char *b = sb->buf;
82
- while (sb->len > 0 && isspace((unsigned char)sb->buf[sb->len - 1]))
83
- sb->len--;
84
- while (sb->len > 0 && isspace(*b)) {
85
- b++;
86
- sb->len--;
87
- }
88
- memmove(sb->buf, b, sb->len);
89
- sb->buf[sb->len] = '\0';
81
+ strbuf_rtrim(sb);
82
+ strbuf_ltrim(sb);
83
}
84
void strbuf_rtrim(struct strbuf *sb)
85
{