Can a catch attempt in C ++ affect performance if not hit

I have code where there is a catch attempt in a function, and the function hits. 100+ times. The code returns early every time, without clicking on the try catch. This affects performance in Visual Studio. I see the impact of performance.

My code is:

void foo(int a) {
 if (a > value) {
    return;
 }
 try {
    possibleErrorFunction();
 } catch {
 }
}

I changed it to:

void foo(int a) {
if (a > value) {
    return;
}
bar();
}

void bar() {
try {
    possibleErrorFunction();
} catch {
}
}

The second code looks about 10 seconds faster. Is there any elusive explanation for this?

+4
source share
2 answers

. - " " "", - " ". .

, try . " " , , .

100%, , Microsoft VS2008 " " , VS2010 "" . ( , , - , , ). , .

++, , try

+1

, , . , , ( , "" ). .

0

All Articles