mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-25 12:52:29 +03:00
leak
This commit is contained in:
parent
fcadf4511a
commit
39858ce1ff
@ -162,32 +162,25 @@ const TargetPhraseCollection *PhraseDictionaryOnDisk::GetTargetPhraseCollection(
|
||||
{
|
||||
const TargetPhraseCollection *ret;
|
||||
|
||||
if (m_maxCacheSize) {
|
||||
CacheColl &cache = GetCache();
|
||||
size_t hash = (size_t) ptNode->GetFilePos();
|
||||
CacheColl &cache = GetCache();
|
||||
size_t hash = (size_t) ptNode->GetFilePos();
|
||||
|
||||
std::map<size_t, std::pair<const TargetPhraseCollection*, clock_t> >::iterator iter;
|
||||
std::map<size_t, std::pair<const TargetPhraseCollection*, clock_t> >::iterator iter;
|
||||
|
||||
iter = cache.find(hash);
|
||||
iter = cache.find(hash);
|
||||
|
||||
if (iter == cache.end()) {
|
||||
// not in cache, need to look up from phrase table
|
||||
ret = GetTargetPhraseCollectionNonCache(ptNode);
|
||||
if (ret) {
|
||||
ret = new TargetPhraseCollection(*ret);
|
||||
}
|
||||
|
||||
std::pair<const TargetPhraseCollection*, clock_t> value(ret, clock());
|
||||
cache[hash] = value;
|
||||
} else {
|
||||
// in cache. just use it
|
||||
std::pair<const TargetPhraseCollection*, clock_t> &value = iter->second;
|
||||
value.second = clock();
|
||||
|
||||
ret = value.first;
|
||||
}
|
||||
} else {
|
||||
if (iter == cache.end()) {
|
||||
// not in cache, need to look up from phrase table
|
||||
ret = GetTargetPhraseCollectionNonCache(ptNode);
|
||||
|
||||
std::pair<const TargetPhraseCollection*, clock_t> value(ret, clock());
|
||||
cache[hash] = value;
|
||||
} else {
|
||||
// in cache. just use it
|
||||
std::pair<const TargetPhraseCollection*, clock_t> &value = iter->second;
|
||||
value.second = clock();
|
||||
|
||||
ret = value.first;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user