Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit c64ab9d

Browse files
committed
Avoid redundant condition test
_pLastAppliedConfiguration != NULL is tested twice as we know that pApplicableDomainConfiguration is not null. This patch avoids this double test and merge the two conditions. Signed-off-by: Jules Clero <[email protected]>
1 parent 0337422 commit c64ab9d

File tree

1 file changed

+13
-16
lines changed

1 file changed

+13
-16
lines changed

parameter/ConfigurableDomain.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -530,27 +530,24 @@ void CConfigurableDomain::apply(
530530
}
531531
const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();
532532

533-
if (pApplicableDomainConfiguration) {
534-
535-
// Check not the last one before applying
536-
if (!_pLastAppliedConfiguration || _pLastAppliedConfiguration != pApplicableDomainConfiguration) {
533+
// Check the last applied configuration is different from this one before apply
534+
if (pApplicableDomainConfiguration != NULL and _pLastAppliedConfiguration != pApplicableDomainConfiguration) {
537535

538-
log_info("Applying configuration \"%s\" from domain \"%s\"",
539-
pApplicableDomainConfiguration->getName().c_str(),
540-
getName().c_str());
536+
log_info("Applying configuration \"%s\" from domain \"%s\"",
537+
pApplicableDomainConfiguration->getName().c_str(),
538+
getName().c_str());
541539

542-
// Do the restore, and synchronize if we are sequence aware
543-
pApplicableDomainConfiguration->restore(pParameterBlackboard, _bSequenceAware, NULL);
540+
// Do the restore, and synchronize if we are sequence aware
541+
pApplicableDomainConfiguration->restore(pParameterBlackboard, _bSequenceAware, NULL);
544542

545-
// Record last applied configuration
546-
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
543+
// Record last applied configuration
544+
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
547545

548-
// Check we need to provide syncer set to caller
549-
if (!_bSequenceAware) {
546+
// Check we need to provide syncer set to caller
547+
if (!_bSequenceAware) {
550548

551-
// Since we applied changes, add our own sync set to the given one
552-
syncerSet += _syncerSet;
553-
}
549+
// Since we applied changes, add our own sync set to the given one
550+
syncerSet += _syncerSet;
554551
}
555552
}
556553
}

0 commit comments

Comments
 (0)