Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
pretty: remove intermediate strbufs from pp_user_info()
author
René Scharfe
<rene.scharfe@lsrfire.ath.cx>
Thu, 25 Apr 2013 19:43:56 +0000
(21:43 +0200)
committer
Junio C Hamano
<gitster@pobox.com>
Thu, 25 Apr 2013 22:02:54 +0000
(15:02 -0700)
Use namebuf/namelen and mailbuf/maillen directly instead of copying
their contents into strbufs first.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pretty.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
97a17e7
)
diff --git
a/pretty.c
b/pretty.c
index 2031c77f156d2a8f47e9c23e466934e30c99f2d1..0530abfa727df91b42395a08cd94fd4634a6207e 100644
(file)
--- a/
pretty.c
+++ b/
pretty.c
@@
-410,8
+410,6
@@
void pp_user_info(const struct pretty_print_context *pp,
const char *what, struct strbuf *sb,
const char *line, const char *encoding)
{
const char *what, struct strbuf *sb,
const char *line, const char *encoding)
{
- struct strbuf name;
- struct strbuf mail;
struct ident_split ident;
char *line_end;
const char *mailbuf, *namebuf;
struct ident_split ident;
char *line_end;
const char *mailbuf, *namebuf;
@@
-433,42
+431,33
@@
void pp_user_info(const struct pretty_print_context *pp,
if (pp->mailmap)
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
if (pp->mailmap)
map_user(pp->mailmap, &mailbuf, &maillen, &namebuf, &namelen);
- strbuf_init(&mail, 0);
- strbuf_init(&name, 0);
-
- strbuf_add(&mail, mailbuf, maillen);
- strbuf_add(&name, namebuf, namelen);
-
if (pp->fmt == CMIT_FMT_EMAIL) {
strbuf_addstr(sb, "From: ");
if (pp->fmt == CMIT_FMT_EMAIL) {
strbuf_addstr(sb, "From: ");
- if (needs_rfc2047_encoding(name
.buf, name.
len, RFC2047_ADDRESS)) {
- add_rfc2047(sb, name
.buf, name.
len,
+ if (needs_rfc2047_encoding(name
buf, name
len, RFC2047_ADDRESS)) {
+ add_rfc2047(sb, name
buf, name
len,
encoding, RFC2047_ADDRESS);
max_length = 76; /* per rfc2047 */
encoding, RFC2047_ADDRESS);
max_length = 76; /* per rfc2047 */
- } else if (needs_rfc822_quoting(name
.buf, name.
len)) {
+ } else if (needs_rfc822_quoting(name
buf, name
len)) {
struct strbuf quoted = STRBUF_INIT;
struct strbuf quoted = STRBUF_INIT;
- add_rfc822_quoted("ed, name
.buf, name.
len);
+ add_rfc822_quoted("ed, name
buf, name
len);
strbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,
-6, 1, max_length);
strbuf_release("ed);
} else {
strbuf_add_wrapped_bytes(sb, quoted.buf, quoted.len,
-6, 1, max_length);
strbuf_release("ed);
} else {
- strbuf_add_wrapped_bytes(sb, name
.buf, name.
len,
+ strbuf_add_wrapped_bytes(sb, name
buf, name
len,
-6, 1, max_length);
}
if (max_length <
last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
strbuf_addch(sb, '\n');
-6, 1, max_length);
}
if (max_length <
last_line_length(sb) + strlen(" <") + maillen + strlen(">"))
strbuf_addch(sb, '\n');
- strbuf_addf(sb, " <%
s>\n", mail.
buf);
+ strbuf_addf(sb, " <%
.*s>\n", (int)maillen, mail
buf);
} else {
} else {
- strbuf_addf(sb, "%s: %.*s%
s <%
s>\n", what,
-
(pp->fmt == CMIT_FMT_FULLER) ? 4 : 0
,
-
" ", name.buf, mail.
buf);
+ strbuf_addf(sb, "%s: %.*s%
.*s <%.*
s>\n", what,
+
(pp->fmt == CMIT_FMT_FULLER) ? 4 : 0, " "
,
+
(int)namelen, namebuf, (int)maillen, mail
buf);
}
}
- strbuf_release(&mail);
- strbuf_release(&name);
-
switch (pp->fmt) {
case CMIT_FMT_MEDIUM:
strbuf_addf(sb, "Date: %s\n",
switch (pp->fmt) {
case CMIT_FMT_MEDIUM:
strbuf_addf(sb, "Date: %s\n",