From fca444bc040c0a020db41711fcc72a8eb634f295 Mon Sep 17 00:00:00 2001 From: "waterson%netscape.com" Date: Fri, 7 Apr 2000 19:22:59 +0000 Subject: [PATCH] Bug 34726. Add an out parameter to ConflictSet::Add() that indicates whether the new instantiation triggered any new rules to be matched. The caller then uses this parameter to decide whether or not to add the key of a rule cluster to the 'newkeys' set. r=rjc, a=leaf git-svn-id: svn://10.0.0.236/trunk@65500 18797224-902f-48f8-a5cc-f745e15eee43 --- .../xul/templates/src/nsXULTemplateBuilder.cpp | 17 ++++++++++++----- .../rdf/content/src/nsXULTemplateBuilder.cpp | 17 ++++++++++++----- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp index 69d3eac2b39..04c93a6158b 100644 --- a/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp +++ b/mozilla/content/xul/templates/src/nsXULTemplateBuilder.cpp @@ -918,7 +918,7 @@ public: ConflictSet(); ~ConflictSet(); - nsresult Add(const Instantiation& aInstantiation, const Rule* aRule); + nsresult Add(const Instantiation& aInstantiation, const Rule* aRule, PRBool* aDidAddKey); void GetMatches(const Key& aKey, const MatchSet** aMatchSet) const; @@ -1097,8 +1097,10 @@ ConflictSet::Destroy() } nsresult -ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule) +ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule, PRBool* aDidAddKey) { + *aDidAddKey = PR_FALSE; + // add the match to a table indexed by instantiation key { Key key(aInstantiation, aRule); @@ -1130,6 +1132,7 @@ ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule) if (! set->Contains(aRule, aInstantiation)) { set->Add(aRule, aInstantiation); + *aDidAddKey = PR_TRUE; } } @@ -1315,12 +1318,16 @@ InstantiationNode::Propogate(const InstantiationSet& aInstantiations, void* aClo // If we get here, we've matched the rule associated with this // node. Add it to the conflict set, and the set of new pairs. - KeySet* keyset = NS_STATIC_CAST(KeySet*, aClosure); + KeySet* newkeys = NS_STATIC_CAST(KeySet*, aClosure); InstantiationSet::ConstIterator last = aInstantiations.Last(); for (InstantiationSet::ConstIterator inst = aInstantiations.First(); inst != last; ++inst) { - mConflictSet->Add(*inst, mRule); - keyset->Add(Key(*inst, mRule)); + PRBool didAddKey; + mConflictSet->Add(*inst, mRule, &didAddKey); + + if (didAddKey) { + newkeys->Add(Key(*inst, mRule)); + } } return NS_OK; diff --git a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp index 69d3eac2b39..04c93a6158b 100644 --- a/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp +++ b/mozilla/rdf/content/src/nsXULTemplateBuilder.cpp @@ -918,7 +918,7 @@ public: ConflictSet(); ~ConflictSet(); - nsresult Add(const Instantiation& aInstantiation, const Rule* aRule); + nsresult Add(const Instantiation& aInstantiation, const Rule* aRule, PRBool* aDidAddKey); void GetMatches(const Key& aKey, const MatchSet** aMatchSet) const; @@ -1097,8 +1097,10 @@ ConflictSet::Destroy() } nsresult -ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule) +ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule, PRBool* aDidAddKey) { + *aDidAddKey = PR_FALSE; + // add the match to a table indexed by instantiation key { Key key(aInstantiation, aRule); @@ -1130,6 +1132,7 @@ ConflictSet::Add(const Instantiation& aInstantiation, const Rule* aRule) if (! set->Contains(aRule, aInstantiation)) { set->Add(aRule, aInstantiation); + *aDidAddKey = PR_TRUE; } } @@ -1315,12 +1318,16 @@ InstantiationNode::Propogate(const InstantiationSet& aInstantiations, void* aClo // If we get here, we've matched the rule associated with this // node. Add it to the conflict set, and the set of new pairs. - KeySet* keyset = NS_STATIC_CAST(KeySet*, aClosure); + KeySet* newkeys = NS_STATIC_CAST(KeySet*, aClosure); InstantiationSet::ConstIterator last = aInstantiations.Last(); for (InstantiationSet::ConstIterator inst = aInstantiations.First(); inst != last; ++inst) { - mConflictSet->Add(*inst, mRule); - keyset->Add(Key(*inst, mRule)); + PRBool didAddKey; + mConflictSet->Add(*inst, mRule, &didAddKey); + + if (didAddKey) { + newkeys->Add(Key(*inst, mRule)); + } } return NS_OK;