Skip to content

Commit 8d099fd

Browse files
committed
sub-process: do not use strbuf_split*()
The code to read status from subprocess reads one packet line and tries to find "status=<foo>". It is way overkill to split the line into an array of two strbufs to extract <foo>. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 858d376 commit 8d099fd

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

sub-process.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,20 @@ struct subprocess_entry *subprocess_find_entry(struct hashmap *hashmap, const ch
3030

3131
int subprocess_read_status(int fd, struct strbuf *status)
3232
{
33-
struct strbuf **pair;
34-
char *line;
3533
int len;
3634

3735
for (;;) {
36+
char *line;
37+
const char *value;
38+
3839
len = packet_read_line_gently(fd, NULL, &line);
3940
if ((len < 0) || !line)
4041
break;
41-
pair = strbuf_split_str(line, '=', 2);
42-
if (pair[0] && pair[0]->len && pair[1]) {
42+
if (skip_prefix(line, "status=", &value)) {
4343
/* the last "status=<foo>" line wins */
44-
if (!strcmp(pair[0]->buf, "status=")) {
45-
strbuf_reset(status);
46-
strbuf_addbuf(status, pair[1]);
47-
}
44+
strbuf_reset(status);
45+
strbuf_addstr(status, value);
4846
}
49-
strbuf_list_free(pair);
5047
}
5148

5249
return (len < 0) ? len : 0;

0 commit comments

Comments
 (0)