mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 04:43:03 +03:00
eliminate spurious copy / memory leak
This commit is contained in:
parent
60cae6418f
commit
7123d1cc80
@ -80,12 +80,12 @@ void ChartRuleLookupManagerMemory::GetChartRuleCollection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy temporarily stored rules to out collection
|
// 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) {
|
for (vector<CompletedRule*>::const_iterator iter = rules.begin(); iter != rules.end(); ++iter) {
|
||||||
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
|
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_completedRules[absEndPos].Clear();
|
rules.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,12 +80,12 @@ void ChartRuleLookupManagerMemoryPerSentence::GetChartRuleCollection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// copy temporarily stored rules to out collection
|
// 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) {
|
for (vector<CompletedRule*>::const_iterator iter = rules.begin(); iter != rules.end(); ++iter) {
|
||||||
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
|
outColl.Add((*iter)->GetTPC(), (*iter)->GetStackVector(), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_completedRules[absEndPos].Clear();
|
rules.Clear();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,11 @@ CompletedRuleCollection::CompletedRuleCollection() : m_ruleLimit(StaticData::Ins
|
|||||||
m_scoreThreshold = numeric_limits<float>::infinity();
|
m_scoreThreshold = numeric_limits<float>::infinity();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CompletedRuleCollection::~CompletedRuleCollection()
|
||||||
|
{
|
||||||
|
Clear();
|
||||||
|
}
|
||||||
|
|
||||||
// copies some functionality (pruning) from ChartTranslationOptionList::Add
|
// copies some functionality (pruning) from ChartTranslationOptionList::Add
|
||||||
void CompletedRuleCollection::Add(const TargetPhraseCollection &tpc,
|
void CompletedRuleCollection::Add(const TargetPhraseCollection &tpc,
|
||||||
const StackVec &stackVec,
|
const StackVec &stackVec,
|
||||||
|
@ -75,6 +75,7 @@ struct CompletedRuleCollection {
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
CompletedRuleCollection();
|
CompletedRuleCollection();
|
||||||
|
~CompletedRuleCollection();
|
||||||
|
|
||||||
CompletedRuleCollection(const CompletedRuleCollection &old)
|
CompletedRuleCollection(const CompletedRuleCollection &old)
|
||||||
: m_collection(old.m_collection)
|
: m_collection(old.m_collection)
|
||||||
|
Loading…
Reference in New Issue
Block a user