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,
if (match->n == 1)
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",
obj, method, match->n);
return (UINT_MAX);
}
if (selects == vmod_enum_FIRST)
case 'L':
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;
if (selects == vmod_enum_LAST)
return match->max;
if (selects == vmod_enum_SHORTEST)
case 'S':
assert(selects == vmod_enum_SHORTEST);
return match->indices[0];
if (selects == vmod_enum_LONGEST)
return match->indices[match->n - 1];
WRONG("illegal select enum");
return (UINT_MAX);
default:
WRONG("illegal select enum");
}
}
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