As far as I understand the concept, CC is determined by how many nested branched logic the given method have. It can be refactored to checking the opposite of original predicate and calling return. For example:
void Foo()
{
if (predicate0)
{
if (predicate1)
{
// some code
}
}
}
can be refactored to
void Foo()
{
if (!predicate0) return;
if (!predicate1) return;
// some code
}
but the thing is, following the branch predicate0 && predicate1
will generate less cache misses in C++ if this path is taken much more frequently.
Obviously, I am intentionally simplifying the code. For example, there can be dozens of predicates and things like one predicate dependency on another predicate.
What to do in this case? Should I throw away performance for better readability?