Removing a if/else is like removing 2-3 cycles and clocked a 2-3GHz, it represents nothing.
Between the two.
Code:
if (path.EndsWith(".dbc"))
return true;
else
return false;
I would use this:
Code:
if (path.EndsWith(".dbc"))
return true;
return false;
But, the best thing would be:
Code:
return path.EndsWith(".dbc");
Actually, in the industry using or not the else is not so important. But, we shouldn't have multiple return statement. In C#, it can be less important due to the memory management. In C/C++, it is less recommended due to the complex memory management (it can cause memory leak). Also, it's harder to debug. In case of little check at the start of the function, it's not important. But, later it's not recommended. Anyway, in this case, it's not a problem to have multiple return statement, but, we can write the function in one line and possibly, make it inline in C/C++ to avoid useless call that will slow of a few cycle :rolleyes: