Commit e87c2c47 by Geoff Simmons

Optimize set.matched().

Take advantage of the fact that the array of indexes returned from
the vre2 call is now sorted (but still using a linear search).
parent af7001b1
Pipeline #342 skipped
......@@ -768,6 +768,7 @@ VCL_BOOL
vmod_set_matched(VRT_CTX, struct vmod_re2_set *set, VCL_INT n)
{
struct task_set_match *task;
unsigned i;
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(set, VMOD_RE2_SET_MAGIC);
......@@ -788,10 +789,9 @@ vmod_set_matched(VRT_CTX, struct vmod_re2_set *set, VCL_INT n)
WS_Assert_Allocated(ctx->ws, task->matches,
task->nmatches * sizeof(int));
n--;
for (unsigned i = 0; i < task->nmatches; i++)
if (task->matches[i] == n)
return 1;
return 0;
for (i = 0; i < task->nmatches && task->matches[i] < n; i++)
;
return task->matches[i] == n;
}
VCL_INT
......
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