diff options
author | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-19 18:52:06 +0300 |
---|---|---|
committer | Hieu Hoang <hieuhoang@gmail.com> | 2015-10-19 18:52:06 +0300 |
commit | 7d98df2b0c39007c9167c505b73df5ef31ffd69c (patch) | |
tree | 3a6c2745a42cea621b3021e6585df21ace0ca1a2 /moses/HypothesisStackCubePruning.cpp | |
parent | b700f99afb6b3e0444c592b01b798057b99327bc (diff) |
reuse bitmap key for BitmapContainer
Diffstat (limited to 'moses/HypothesisStackCubePruning.cpp')
-rw-r--r-- | moses/HypothesisStackCubePruning.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/moses/HypothesisStackCubePruning.cpp b/moses/HypothesisStackCubePruning.cpp index f83c0d234..6d9ebf36a 100644 --- a/moses/HypothesisStackCubePruning.cpp +++ b/moses/HypothesisStackCubePruning.cpp @@ -48,6 +48,7 @@ void HypothesisStackCubePruning::RemoveAll() // delete all bitmap accessors; _BMType::iterator iter; for (iter = m_bitmapAccessor.begin(); iter != m_bitmapAccessor.end(); ++iter) { + delete iter->first; delete iter->second; } } @@ -149,7 +150,8 @@ void HypothesisStackCubePruning::AddInitial(Hypothesis *hypo) "Should have added hypothesis " << *hypo); const WordsBitmap &bitmap = hypo->GetWordsBitmap(); - m_bitmapAccessor[bitmap] = new BitmapContainer(bitmap, *this, m_deterministic); + WordsBitmap *newBitmap = new WordsBitmap(bitmap); + m_bitmapAccessor[newBitmap] = new BitmapContainer(*newBitmap, *this, m_deterministic); } void HypothesisStackCubePruning::PruneToSize(size_t newSize) @@ -255,12 +257,13 @@ void HypothesisStackCubePruning::SetBitmapAccessor(const WordsBitmap &newBitmap , const SquareMatrix &futureScore , const TranslationOptionList &transOptList) { - _BMType::iterator bcExists = m_bitmapAccessor.find(newBitmap); + _BMType::iterator bcExists = m_bitmapAccessor.find(&newBitmap); BitmapContainer *bmContainer; if (bcExists == m_bitmapAccessor.end()) { - bmContainer = new BitmapContainer(newBitmap, stack, m_deterministic); - m_bitmapAccessor[newBitmap] = bmContainer; + WordsBitmap *bm = new WordsBitmap(newBitmap); + bmContainer = new BitmapContainer(*bm, stack, m_deterministic); + m_bitmapAccessor[bm] = bmContainer; } else { bmContainer = bcExists->second; } @@ -297,7 +300,7 @@ HypothesisStackCubePruning::AddHypothesesToBitmapContainers() for (iter = m_hypos.begin() ; iter != m_hypos.end() ; ++iter) { Hypothesis *h = *iter; const WordsBitmap &bitmap = h->GetWordsBitmap(); - BitmapContainer *container = m_bitmapAccessor[bitmap]; + BitmapContainer *container = m_bitmapAccessor[&bitmap]; container->AddHypothesis(h); } } |