From fb80a2fc22c1b24787a3cdfacb33ffd13a750493 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Thu, 18 Feb 2016 10:46:18 -0500 Subject: [PATCH] Revert "start using State pointer" This reverts commit c28010e9f95bf353491bddec969584c0ede19ce7. --- contrib/other-builds/moses2/LM/KENLM.cpp | 17 +++++++---------- contrib/other-builds/moses2/LM/KENLM.h | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/contrib/other-builds/moses2/LM/KENLM.cpp b/contrib/other-builds/moses2/LM/KENLM.cpp index 0058f3ca1..7a6cc15ff 100644 --- a/contrib/other-builds/moses2/LM/KENLM.cpp +++ b/contrib/other-builds/moses2/LM/KENLM.cpp @@ -303,27 +303,24 @@ lm::WordIndex *KENLM::LastIDs(const Hypothesis &hypo, lm::WordIndex *indices) co float KENLM::ScoreAndCache(const Manager &mgr, const lm::ngram::State &in_state, const lm::WordIndex new_word, lm::ngram::State &out_state) const { - MemPool &pool = mgr.GetPool(); //cerr << "score="; float score; - CacheColl &lmCache = *((CacheColl*)mgr.lmCache); + CacheColl &m_lmCache = *((CacheColl*)mgr.lmCache); LMCacheKey key(in_state, new_word); CacheColl::iterator iter; - iter = lmCache.find(key); - if (iter == lmCache.end()) { - lm::ngram::State *newState = new (pool.Allocate()) lm::ngram::State(); - score = m_ngram->Score(in_state, new_word, *newState); + iter = m_lmCache.find(key); + if (iter == m_lmCache.end()) { + score = m_ngram->Score(in_state, new_word, out_state); - LMCacheValue &val = lmCache[key]; + LMCacheValue &val = m_lmCache[key]; val.first = score; - val.second = newState; - out_state = *newState; + val.second = out_state; } else { const LMCacheValue &val = iter->second; score = val.first; - out_state = *val.second; + out_state = val.second; } //score = m_ngram->Score(in_state, new_word, out_state); diff --git a/contrib/other-builds/moses2/LM/KENLM.h b/contrib/other-builds/moses2/LM/KENLM.h index 42803d397..9d9e804c9 100644 --- a/contrib/other-builds/moses2/LM/KENLM.h +++ b/contrib/other-builds/moses2/LM/KENLM.h @@ -81,7 +81,7 @@ protected: std::vector m_lmIdLookup; typedef std::pair LMCacheKey; - typedef std::pair LMCacheValue; + typedef std::pair LMCacheValue; typedef boost::unordered_map CacheColl; mutable boost::thread_specific_ptr m_cache;