From 39858ce1ff7d115e0022ccc7c55184a14c7f2932 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Tue, 21 Jan 2014 18:07:12 +0000 Subject: [PATCH] leak --- .../RuleTable/PhraseDictionaryOnDisk.cpp | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp index 8fa9c4ea2..45b881765 100644 --- a/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp +++ b/moses/TranslationModel/RuleTable/PhraseDictionaryOnDisk.cpp @@ -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 >::iterator iter; + std::map >::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 value(ret, clock()); - cache[hash] = value; - } else { - // in cache. just use it - std::pair &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 value(ret, clock()); + cache[hash] = value; + } else { + // in cache. just use it + std::pair &value = iter->second; + value.second = clock(); + + ret = value.first; } return ret;