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 5, 2015
1 parent 0337422 commit c64ab9d
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions parameter/ConfigurableDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,27 +530,24 @@ void CConfigurableDomain::apply(
}
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 and _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 c64ab9d

Please sign in to comment.