eliminate spurious copy / memory leak

This commit is contained in:
Rico Sennrich 2015-01-07 18:42:20 +00:00
parent 60cae6418f
commit 7123d1cc80
4 changed files with 10 additions and 4 deletions

View File

@ -80,12 +80,12 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection(
}
// copy temporarily stored rules to out collection
CompletedRuleCollection rules = m_completedRules[absEndPos];
CompletedRuleCollection & rules = m_completedRules[absEndPos];
for (vector<CompletedRule*>::const_iterator iter = rules.begin(); iter != rules.end(); ++iter) {
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
}
m_completedRules[absEndPos].Clear();
rules.Clear();
}

View File

@ -80,12 +80,12 @@ void ChartRuleLookupManagerMemoryPerSentence::GetChartRuleCollection(
}
// copy temporarily stored rules to out collection
CompletedRuleCollection rules = m_completedRules[absEndPos];
CompletedRuleCollection & rules = m_completedRules[absEndPos];
for (vector<CompletedRule*>::const_iterator iter = rules.begin(); iter != rules.end(); ++iter) {
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
}
m_completedRules[absEndPos].Clear();
rules.Clear();
}

View File

@ -32,6 +32,11 @@ CompletedRuleCollection::CompletedRuleCollection() : m_ruleLimit(StaticData::Ins
m_scoreThreshold = numeric_limits<float>::infinity();
}
CompletedRuleCollection::~CompletedRuleCollection()
{
Clear();
}
// copies some functionality (pruning) from ChartTranslationOptionList::Add
void CompletedRuleCollection::Add(const TargetPhraseCollection &tpc,
const StackVec &stackVec,

View File

@ -75,6 +75,7 @@ struct CompletedRuleCollection {
public:
CompletedRuleCollection();
~CompletedRuleCollection();
CompletedRuleCollection(const CompletedRuleCollection &old)
: m_collection(old.m_collection)