Commit fe2da4d4 authored by Geoff Simmons's avatar Geoff Simmons

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

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