Commit 01c613af authored by Nils Goroll's avatar Nils Goroll

micro-optimize backref when the reference is the subject tail

test is already included in c01.vtc
parent a289ca4f
...@@ -237,8 +237,11 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, struct vmod_priv *task) ...@@ -237,8 +237,11 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, struct vmod_priv *task)
start = ov->subject + ov->ovector[refnum]; start = ov->subject + ov->ovector[refnum];
len = ov->ovector[refnum+1] - ov->ovector[refnum]; len = ov->ovector[refnum+1] - ov->ovector[refnum];
assert(len <= ov->ovector[1] - ov->ovector[0]); assert(len <= ov->ovector[1] - ov->ovector[0]);
WS_Assert_Allocated(ctx->ws, start, len); WS_Assert_Allocated(ctx->ws, start, len + 1);
substr = WS_Printf(ctx->ws, "%.*s", len, start); if (start[len] == '\0')
substr = start;
else
substr = WS_Printf(ctx->ws, "%.*s", len, start);
if (substr == NULL) { if (substr == NULL) {
VSLb(ctx->vsl, SLT_VCL_Error, VSLb(ctx->vsl, SLT_VCL_Error,
"vmod re: insufficient workspace"); "vmod re: insufficient workspace");
......
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