@obfuscated: I agree with you that measuring is vastly superior to guessing.
And I consider it absolutely critical to make sure that no regressions creep in.
Be it functional or in performance. Thanks for taking that serious. I want my
beloved cb to work after an update, safely and responsive.
This quite tiny change of signature to const& in this case is rather to
increase clarity, showing the intent (query, probably no sink), beware
(myself) of accidentially changing the parameter within the routine ---
but without sacrificing any performance!
No, I haven't gprofed it yet. Do you have some measurements for this case?
Instead I tried for this tiny change to focus on the correctness and even
punched in a good dozen of Unittest++ Checks into a separate file. Just
to make sure I do not break anything (Testing is for whimps only, right?).
Unfortunately, tests for AddToInfixExpression are still to be done because
it is not testable as simple. And I do not consider #ifdef CC_PARSER_TEST
being a sensible automatic unittest strategy.
More effective-C++ ways to be more efficient-C++ (pun intended) can be found
rather elsewhere E.g.:
ExpressionNode::ExpressionNode()
{
Initialize(wxEmptyString);
}
void ExpressionNode::Initialize(wxString token)
{
m_UnaryOperator = false;
m_Token = token;
m_Type = ParseNodeType(m_Token);
m_Priority = GetNodeTypePriority(m_Type);
}
All data-member are assigned a value twice when the default-ctor is called
and that is done in an inner loop further down. Did you notice that
the order of the assigments is different from the data-member sequence.
Not that this matters here. But that's how errors creep in.
I wanted to start at the smallest building blocks. Having confidence
in them before I work my way further up.
The real dragons lie are, where the complexity is high (have you fed
pmmcabe with CC?) and local reasoning is hard due to friendship,
inheritance, protected data-member and naked pointers. As for performance:
Did you ever try a sizeof(Token). How many do we have?
I hope, that future replies can be a lot shorter;-)