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, ...@@ -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 == VENUM(UNIQUE)) { switch (selects[0]) {
case 'U':
assert(selects == VENUM(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 == VENUM(FIRST)) 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; return match->min;
if (selects == VENUM(LAST)) case 'S':
return match->max; assert(selects == VENUM(SHORTEST));
if (selects == VENUM(SHORTEST))
return match->indices[0]; return match->indices[0];
if (selects == VENUM(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