pretty: use starts_with() to check for a prefix
Simplify the code and avoid duplication by using starts_with() instead of strlen() and strncmp() to check if a line starts with "encoding ". Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
René Scharfe committed
Feb 21, 2015 at 20:53 UTC
68d6d6eb402d7e39c89ce43ca37e6c16b941890c
1 file changed
+1
-1
pretty.c
+1
-1
@@ -586,7 +586,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
586
char *cp = buf;
587
588
/* guess if there is an encoding header before a \n\n */
589
- while (strncmp(cp, "encoding ", strlen("encoding "))) {
589
+ while (!starts_with(cp, "encoding ")) {
590
cp = strchr(cp, '\n');
591
if (!cp || *++cp == '\n')
592
return buf;