Commit c59c6088 authored by Geoff Simmons's avatar Geoff Simmons

Refactor decoding the SELECT enum, so that there may be fewer compares.

parent 99263381
...@@ -547,21 +547,27 @@ select(VRT_CTX, const struct match_data * const restrict match, ...@@ -547,21 +547,27 @@ select(VRT_CTX, const struct match_data * const restrict match,
if (match->n == 1) if (match->n == 1)
return match->indices[0]; return match->indices[0];
if (selects == vmod_enum_UNIQUE) { switch (selects[0]) {
case 'U':
assert(selects == vmod_enum_UNIQUE);
VERR(ctx, "%s.%s(select=UNIQUE): %d elements were matched", VERR(ctx, "%s.%s(select=UNIQUE): %d elements were matched",
obj, method, match->n); obj, method, match->n);
return (UINT_MAX); return (UINT_MAX);
} case 'L':
if (selects == vmod_enum_FIRST) if (selects == vmod_enum_LAST)
return match->max;
if (selects == vmod_enum_LONGEST)
return match->indices[match->n - 1];
WRONG("illegal select enum");
case 'F':
assert(selects == vmod_enum_FIRST);
return match->min; return match->min;
if (selects == vmod_enum_LAST) case 'S':
return match->max; assert(selects == vmod_enum_SHORTEST);
if (selects == vmod_enum_SHORTEST)
return match->indices[0]; return match->indices[0];
if (selects == vmod_enum_LONGEST) default:
return match->indices[match->n - 1]; WRONG("illegal select enum");
WRONG("illegal select enum"); }
return (UINT_MAX);
} }
VCL_INT 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