[Issue 13169] New: Optimization - final switch need not check for default case
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Jul 20 14:13:48 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13169
Issue ID: 13169
Summary: Optimization - final switch need not check for default
case
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: bugzilla at digitalmars.com
void A();
void B();
void C();
void D();
void E();
void test(int i)
{
while (1)
{
final switch (i)
{
case 1: A(); break;
case 2: B(); break;
case 3: C(); break;
case 4: D(); break;
case 5: E(); break;
}
++i;
}
}
An overflow check is done before dispatch, even with -O -release
-noboundscheck.
See also:
http://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables/
--
More information about the Digitalmars-d-bugs
mailing list