use strchrnul() in place of strchr() and strlen()
Avoid scanning strings twice, once with strchr() and then with strlen(), by using strchrnul(). Helped-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Rohit Mani <rohit.mani@outlook.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
5f95c9f850
commit
2c5495f7b6
@ -78,8 +78,8 @@ static int parse_rev_note(const char *msg, struct rev_note *res)
|
||||
size_t len;
|
||||
|
||||
while (*msg) {
|
||||
end = strchr(msg, '\n');
|
||||
len = end ? end - msg : strlen(msg);
|
||||
end = strchrnul(msg, '\n');
|
||||
len = end - msg;
|
||||
|
||||
key = "Revision-number: ";
|
||||
if (starts_with(msg, key)) {
|
||||
|
Reference in New Issue
Block a user