mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
strbuf: add and use strbuf_insertstr()
Add a function for inserting a C string into a strbuf. Use it throughout the source to get rid of magic string length constants and explicit strlen() calls. Like strbuf_addstr(), implement it as an inline function to avoid the implicit strlen() calls to cause runtime overhead. Helped-by: Taylor Blau <me@ttaylorr.com> Helped-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
d0654dc308
commit
a91cc7fad0
@@ -254,7 +254,7 @@ static void handle_content_type(struct mailinfo *mi, struct strbuf *line)
|
||||
mi->delsp = has_attr_value(line->buf, "delsp=", "yes");
|
||||
|
||||
if (slurp_attr(line->buf, "boundary=", boundary)) {
|
||||
strbuf_insert(boundary, 0, "--", 2);
|
||||
strbuf_insertstr(boundary, 0, "--");
|
||||
if (++mi->content_top >= &mi->content[MAX_BOUNDARIES]) {
|
||||
error("Too many boundaries to handle");
|
||||
mi->input_error = -1;
|
||||
@@ -570,7 +570,7 @@ static int check_header(struct mailinfo *mi,
|
||||
len = strlen("Content-Type: ");
|
||||
strbuf_add(&sb, line->buf + len, line->len - len);
|
||||
decode_header(mi, &sb);
|
||||
strbuf_insert(&sb, 0, "Content-Type: ", len);
|
||||
strbuf_insertstr(&sb, 0, "Content-Type: ");
|
||||
handle_content_type(mi, &sb);
|
||||
ret = 1;
|
||||
goto check_header_out;
|
||||
|
||||
Reference in New Issue
Block a user