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

Commit

Permalink
Avoid redundant condition test
Browse files Browse the repository at this point in the history
_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]>
  • Loading branch information
clero committed Mar 9, 2015
1 parent 24b9f6e commit ac259c3
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -529,27 +529,25 @@ void CConfigurableDomain::apply(CParameterBlackboard* pParameterBlackboard,
}
const CDomainConfiguration* pApplicableDomainConfiguration = findApplicableDomainConfiguration();

if (pApplicableDomainConfiguration) {

// Check not the last one before applying
if (!_pLastAppliedConfiguration || _pLastAppliedConfiguration != pApplicableDomainConfiguration) {
// Check the last applied configuration is different from this one before apply
if (pApplicableDomainConfiguration != NULL &&
_pLastAppliedConfiguration != pApplicableDomainConfiguration) {

log_info("Applying configuration \"%s\" from domain \"%s\"",
pApplicableDomainConfiguration->getName().c_str(),
getName().c_str());
log_info("Applying configuration \"%s\" from domain \"%s\"",
pApplicableDomainConfiguration->getName().c_str(),
getName().c_str());

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

// Record last applied configuration
_pLastAppliedConfiguration = pApplicableDomainConfiguration;
// Record last applied configuration
_pLastAppliedConfiguration = pApplicableDomainConfiguration;

// Check we need to provide syncer set to caller
if (!_bSequenceAware) {
// Check we need to provide syncer set to caller
if (!_bSequenceAware) {

// Since we applied changes, add our own sync set to the given one
syncerSet += _syncerSet;
}
// Since we applied changes, add our own sync set to the given one
syncerSet += _syncerSet;
}
}
}
Expand Down

0 comments on commit ac259c3

Please sign in to comment.