Commit 5cae714f authored by Geoff Simmons's avatar Geoff Simmons

Avoid copying for enc == dec if we can

Patch from Nils Goroll
parent 29156901
......@@ -572,9 +572,21 @@ transcode(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
/*
* If the encoding and decoding are the same, and the decoding was
* legal, just return the concatenated string.
* legal, just return the string, if there was only one in the
* STRING_LIST, or else the concatenated string.
*/
if (n == -1 && enc == dec) {
const char *q, *pp = p;
va_copy(aq, ap);
q = find_nonempty_va(&pp, ap);
va_end(aq);
if (pp == vrt_magic_string_end)
return "";
if (q == vrt_magic_string_end)
return pp;
r = VRT_String(ctx->ws, NULL, p, ap);
return r;
}
......@@ -598,7 +610,7 @@ vmod_transcode(VRT_CTX, VCL_ENUM decs, VCL_ENUM encs,
VCL_STRING __match_proto__(td_blobcode_transcode_n)
vmod_transcode_n(VRT_CTX, VCL_INT n, VCL_ENUM decs, VCL_ENUM encs,
const char *p, ...) {
const char *p, ...) {
va_list ap;
VCL_STRING r;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment