mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-02 17:09:36 +03:00
use pointer in key
This commit is contained in:
parent
ec48a33b7c
commit
afd5352712
@ -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()) {
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user