Mercurial > dedupe
view CachedEditDistance.cpp @ 99:b821d6270741
If we have turned USE_BOOST on, we actually require the packages.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Thu, 13 Feb 2014 14:53:35 +0100 |
| parents | 9744ec195be3 |
| children |
line wrap: on
line source
#include "CachedEditDistance.hpp" #include "CompileTimeConstants.h" #include "ConfigurationProcessing.hpp" CachedEditDistance::cacheType* CachedEditDistance::cache = 0; //CachedEditDistance::cacheType CachedEditDistance::cache; int CachedEditDistance::Compute(QString a, QString b, bool remove) { if (remove) { removeDiacriticsNoCopy(a); removeDiacriticsNoCopy(b); } if ( a == b) return 0; OrderedPair<UniqueString> lup(a, b); if (cache == 0) { QString cacheLocation = processSetupVariables(EDITDISTANCE_CACHE_LOCATION); CachedEditDistance::cache = new cacheType(cacheLocation, "EditLUT"); } boost::optional<int> res = cache->value(lup); if (res) return *res; int retVal = EditDistance::Compute(a, b, false); cache->insert(lup, retVal); return retVal; }
