3 ms·
Compiling with exceptions can still have performance cost because the addition of implicit control flow at every function call. For example the following code
by muizelaar 9y ago
Compiling with exceptions can still have performance cost because the addition of implicit control flow at every function call.
For example the following code will compile differently depending on whether goo() can throw.
struct k
{
void p[4];
};
void goo(k s);
k foo() {
k r;
k s;
goo(&s);
r = s;
return r;
}
If goo() doesn't throw the extra variable s can be eliminated.
- aristidb 9y agoTry indenting your code section by 4 spaces. :)
- int_19h 9y agoIf goo doesn't throw, why not declare it nothrow? Although I still don't see why, in your example, one of the variables cannot be elided even if goo does throw. Since there's no point at which address of r is taken, much less escapes the scope, it should always be safe to elide r and just return s, no?
- deleted 9y ago[deleted]
- flamedoge 9y agoyou mean r? you can't eliminate s regardless of goo throwing.