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

Commit ac259c3

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 24b9f6e commit ac259c3

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

parameter/ConfigurableDomain.cpp

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -529,27 +529,25 @@ void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard,
529529
}
530530
const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();
531531

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

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

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

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

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

550-
// Since we applied changes, add our own sync set to the given one
551-
syncerSet += _syncerSet;
552-
}
549+
// Since we applied changes, add our own sync set to the given one
550+
syncerSet += _syncerSet;
553551
}
554552
}
555553
}

0 commit comments

Comments
 (0)