switch (val)
{
case ENUM_A:
do_A();
break;
case ENUM_B:
case ENUM_C:
default:
do_default();
break;
}
I remember this pretty clearly b/c I know exactly how it reached this point. The code used to be like this:
switch (val)
{
case ENUM_A:
do_A();
break;
case ENUM_B:
do_B();
break;
case ENUM_C:
do_C();
break;
default:
do_default();
break;
}
However, as code was condensed and options eliminated, people removed only the portion of code that was necessary to remove. Only after looking at the code from a distance does someone finally realize this should be condensed to something far more reasonable (and removing the unnecessary enums too):
if (NEW_BOOL_FLAG) do_A(); else do_default();
No comments:
Post a Comment