diff --git a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp index 5eace2063..9fe9eec30 100644 --- a/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp +++ b/moses/TranslationModel/CompactPT/LexicalReorderingTableCreator.cpp @@ -258,8 +258,10 @@ void LexicalReorderingTableCreator::FlushEncodedQueue(bool force) if(force) { m_lastFlushedLine = -1; - m_hash.AddRange(m_lastRange); - m_lastRange.clear(); + if(!m_lastRange.empty()) { + m_hash.AddRange(m_lastRange); + m_lastRange.clear(); + } #ifdef WITH_THREADS m_hash.WaitAll(); @@ -377,7 +379,6 @@ void EncodingTaskReordering::operator()() encodedLine, i); result.push_back(packedItem); } - lines.clear(); { #ifdef WITH_THREADS @@ -388,6 +389,7 @@ void EncodingTaskReordering::operator()() m_creator.FlushEncodedQueue(); } + lines.clear(); result.clear(); lines.reserve(max_lines); result.reserve(max_lines); diff --git a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp index 6de3340d1..ba1dfc578 100644 --- a/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp +++ b/moses/TranslationModel/CompactPT/PhraseTableCreator.cpp @@ -878,8 +878,10 @@ void PhraseTableCreator::FlushRankedQueue(bool force) } if(force) { - m_rnkHash.AddRange(m_lastSourceRange); - m_lastSourceRange.clear(); + if(!m_lastSourceRange.empty()) { + m_rnkHash.AddRange(m_lastSourceRange); + m_lastSourceRange.clear(); + } #ifdef WITH_THREADS m_rnkHash.WaitAll(); @@ -963,8 +965,10 @@ void PhraseTableCreator::FlushEncodedQueue(bool force) m_lastCollection.clear(); } - m_srcHash.AddRange(m_lastSourceRange); - m_lastSourceRange.clear(); + if(!m_lastSourceRange.empty()) { + m_srcHash.AddRange(m_lastSourceRange); + m_lastSourceRange.clear(); + } #ifdef WITH_THREADS m_srcHash.WaitAll();