Message352782
I prefer to keep it a macro. The compiler does not know that it is never executed, so it can generate a suboptimal code.
While it is a macro, it can be made a no-op, or even with compiler-specific instructions like __builtin_unreachable. This can help the compiler to generate more optimal code. For example, the popular idiom:
switch (kind) {
case PyUnicode_1BYTE_KIND: {
...
break;
}
case PyUnicode_2BYTE_KIND: {
...
break;
}
case PyUnicode_4BYTE_KIND: {
...
break;
}
default: Py_UNREACHABLE();
}
could be compiled to the code equivalent to:
if (kind == PyUnicode_1BYTE_KIND) {
...
break;
}
else if (kind == PyUnicode_2BYTE_KIND) {
...
break;
}
else { // assuming (kind == PyUnicode_4BYTE_KIND)
...
break;
} |
|
Date |
User |
Action |
Args |
2019-09-19 09:53:25 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gregory.p.smith, vstinner, zach.ware, malin, ammar2, sir-sigurd |
2019-09-19 09:53:25 | serhiy.storchaka | set | messageid: <1568886805.8.0.216496625364.issue38205@roundup.psfhosted.org> |
2019-09-19 09:53:25 | serhiy.storchaka | link | issue38205 messages |
2019-09-19 09:53:25 | serhiy.storchaka | create | |
|