use pointer in key

This commit is contained in:
Hieu Hoang 2016-02-18 13:40:43 +00:00
parent ec48a33b7c
commit afd5352712
2 changed files with 4 additions and 5 deletions

View File

@ -24,12 +24,11 @@ namespace Moses2
struct KenLMState : public FFState {
const lm::ngram::State *state;
virtual size_t hash() const {
size_t ret = hash_value(*state);
return ret;
return (size_t) state;
}
virtual bool operator==(const FFState& o) const {
const KenLMState &other = static_cast<const KenLMState &>(o);
bool ret = *state == *other.state;
bool ret = state == other.state;
return ret;
}
@ -323,7 +322,7 @@ const KENLM::LMCacheValue &KENLM::ScoreAndCache(const Manager &mgr, const lm::ng
LMCacheValue *val;
CacheColl &lmCache = *((CacheColl*)mgr.lmCache);
LMCacheKey key(in_state, new_word);
LMCacheKey key(&in_state, new_word);
CacheColl::iterator iter;
iter = lmCache.find(key);
if (iter == lmCache.end()) {

View File

@ -80,7 +80,7 @@ protected:
boost::shared_ptr<Model> m_ngram;
std::vector<lm::WordIndex> m_lmIdLookup;
typedef std::pair<lm::ngram::State, lm::WordIndex> LMCacheKey;
typedef std::pair<const lm::ngram::State*, lm::WordIndex> LMCacheKey;
typedef std::pair<float, const lm::ngram::State*> LMCacheValue;
typedef boost::unordered_map<LMCacheKey, LMCacheValue> CacheColl;
mutable boost::thread_specific_ptr<CacheColl> m_cache;