Search code examples
c++performancegcccoding-styleoverhead

Different functions use the same function, reduce overhead


Code:

namespace Dialog {
    enum class Type {Info, Warning, Error};
    enum class Buttons {OK, OK_CANCEL, YES_NO, YES_NO_CANCEL};
    void Box(Pane* parent, Core::String, Core::String, Buttons, Type);
}

I could define InfoBox like this:

void InfoBox(Core::String title, Core::String text, Buttons b) {
    Box(nullptr, title, text, b, Type::Info);
}

but with this approach I have overhead due to the extra function call.

How can I reduce the overhead?


Solution

  • There won't be any. The compiler will trivially inline your function. Even if it didn't, the overhead of the call will add up to absolutely nothing compared to other GUI overheads.