Open Leo-Nogismus opened 1 year ago
Nice catch. If I had a meeting with Eric and could ask one question, it would be about the design of chaining_allowed and the related I_HLP_WEAK_REQUIREMENT_ENABLED. I agree that you found dead code. The code that I commented out was probably planned for a future use. This is part of the reason that I think we should have unit tests. Then we could remove apparently dead code and make sure that the unit tests still pass.
While I was going through the
reduce()
function in themdl_controller.cpp
(both inPrimaryMDLOverlay::reduce(...)
andSecondaryMDLOverlay(...)
), I found some things that are probably just zombie code flying around. Maybe we want to remove them at some point. Listing everything I find here. This can be fixed/ extended at a later date.chaining_allowed
is (I believe) always true in line 166 This comes fromchaining_allowed = (c_s >= WEAK_REQUIREMENT_ENABLED);
on line 143. WithWEAK_REQUIREMENT_ENABLED = 3
andNO_REQUIREMENT = 4
inChainingStatus
this means that in the case ofNO_REQUIREMENT
(as is the case in line 160)c_s
is always true. We should, thus, be able to remove lines 160-162 without any impact on the code.Line 163 is not necessary either. If
c_s
is eitherWEAK_REQUIREMENT_DISABLED
,STRONG_REQUIREMENT_NO_WEAK_REQUIREMENT
, orNO_REQUIREMENT
it follows thatwr_enabled
in line 141 isfalse
(see methodretrieve_imdl_fwd
for more information). Thus, since line 141 statesf_imdl->get_reference(0)->code(I_HLP_WEAK_REQUIREMENT_ENABLED) = Atom::Boolean(wr_enabled);
withwr_enabled = false
it follows that we do not need line 163, which statesf_imdl->get_reference(0)->code(I_HLP_WEAK_REQUIREMENT_ENABLED) = Atom::Boolean(false);
, which is exactly the same thing.Line 254:
chaining_allowed
is not used anywhere later on and thus can be safely removed.Same as 2., but this time on line 262.
I think most of this comes from the removed
or
that removes the need for those checks.