Skip to content

Commit

Permalink
Optimize|Widgets|libcore: Use PointerSet for rule dependency tracking
Browse files Browse the repository at this point in the history
Simpler data structure.
  • Loading branch information
skyjake committed Feb 12, 2017
1 parent 4d1600c commit 6b96143
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions doomsday/sdk/libcore/src/widgets/rule.cpp
Expand Up @@ -19,15 +19,15 @@

#include "de/Rule"
#include "de/math.h"
#include <unordered_set>
#include "de/PointerSet"

namespace de {

bool Rule::_invalidRulesExist = false;

DENG2_PIMPL_NOREF(Rule)
{
typedef std::unordered_set<Rule const *> Dependencies;
typedef PointerSetT<Rule> Dependencies;
Dependencies dependencies; // ref'd

/// Current value of the rule.
Expand All @@ -44,7 +44,7 @@ DENG2_PIMPL_NOREF(Rule)

~Impl()
{
DENG2_ASSERT(dependencies.empty());
DENG2_ASSERT(dependencies.isEmpty());
}
};

Expand Down Expand Up @@ -116,7 +116,7 @@ void Rule::setValue(float v)

void Rule::dependsOn(Rule const &dependency)
{
DENG2_ASSERT(d->dependencies.find(&dependency) == d->dependencies.end());
DENG2_ASSERT(!d->dependencies.contains(&dependency));
d->dependencies.insert(de::holdRef(&dependency));

dependency.audienceForRuleInvalidation += this;
Expand All @@ -131,8 +131,8 @@ void Rule::independentOf(Rule const &dependency)
{
dependency.audienceForRuleInvalidation -= this;

DENG2_ASSERT(d->dependencies.find(&dependency) != d->dependencies.end());
d->dependencies.erase(&dependency);
DENG2_ASSERT(d->dependencies.contains(&dependency));
d->dependencies.remove(&dependency);
dependency.release();
}

Expand Down

0 comments on commit 6b96143

Please sign in to comment.