[m-dev.] for review: MLDS switch optimization

Zoltan Somogyi zs at cs.mu.OZ.AU
Mon Nov 13 16:05:13 AEDT 2000


On 13-Nov-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> 	switch (x) {
> 		case LONGMIN ... -1:
> 			foo();
> 			break;
> 		case 0:
> 			bar();
> 			break;
> 		case 1 ... LONGMAX:
> 			baz();
> 			break;
> 	}

This can be handled by putting an upper limit on the number of elements in a
range that are handled by fallthrough. If the limit is exceeded, you can fall
back on a chain of if-then-elses. I don't think there are any performance
critical cases where this would yield a significant slowdown.

Zoltan.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list