Skip to content

Commit

Permalink
Fixed|libdeng2|ConstantRule: Only invalidate if value actually changes
Browse files Browse the repository at this point in the history
A perf problem was caused by RuleRectangle updating the outputs in
such a manner that caused ConstantRule to be always invalidated.

Todo: Perhaps RuleRectangle could be better implemented with
IndirectRules?
  • Loading branch information
skyjake committed Aug 19, 2013
1 parent abbe8ed commit e8c68ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions doomsday/libdeng2/include/de/widgets/operatorrule.h
Expand Up @@ -57,8 +57,8 @@ class DENG2_PUBLIC OperatorRule : public Rule
return *refless(new OperatorRule(Maximum, left, right));
}

static Rule const &maximum(Rule const &left, Rule const *right) {
if(right) return *refless(new OperatorRule(Maximum, left, *right));
static Rule const &maximum(Rule const &left, Rule const *rightOrNull) {
if(rightOrNull) return *refless(new OperatorRule(Maximum, left, *rightOrNull));
return left;
}

Expand Down
9 changes: 6 additions & 3 deletions doomsday/libdeng2/src/widgets/constantrule.cpp
Expand Up @@ -33,10 +33,13 @@ ConstantRule::ConstantRule(float constantValue)

void ConstantRule::set(float newValue)
{
_pendingValue = newValue;
if(!fequal(_pendingValue, newValue))
{
_pendingValue = newValue;

// Dependent values will need updating.
invalidate();
// Dependent values will need updating.
invalidate();
}
}

String ConstantRule::description() const
Expand Down

0 comments on commit e8c68ad

Please sign in to comment.