Mercurial > dedupe
diff EditDistance.cpp @ 78:9744ec195be3
Encapsulate EditDistance with caching.
| author | Tom Fredrik Blenning Klaussen <bfg@bfgconsult.no> |
|---|---|
| date | Thu, 10 Oct 2013 01:07:52 +0200 |
| parents | 4c283daa42c7 |
| children |
line wrap: on
line diff
--- a/EditDistance.cpp Sat Feb 16 19:00:54 2013 +0100 +++ b/EditDistance.cpp Thu Oct 10 01:07:52 2013 +0200 @@ -1,15 +1,9 @@ #include "EditDistance.hpp" -#include "CompileTimeConstants.h" -#include "ConfigurationProcessing.hpp" - #include <boost/numeric/ublas/matrix.hpp> #define CharComparer(A, B) (QChar(A) == QChar(B)) -EditDistance::cacheType* EditDistance::cache = 0; -//EditDistance::cacheType EditDistance::cache; - void EditDistance::removeDiacriticsNoCopy(QString& in) { for(QString::iterator c = in.begin(); @@ -34,19 +28,6 @@ removeDiacriticsNoCopy(b); } - if ( a == b) - return 0; - - OrderedPair<UniqueString> lup(a, b); - - if (cache == 0) { - QString cacheLocation = processSetupVariables(EDITDISTANCE_CACHE_LOCATION); - EditDistance::cache = new cacheType(cacheLocation, "EditLUT"); - } - boost::optional<int> res = cache->value(lup); - if (res) - return *res; - uint s1 = a.size(); uint s2 = b.size(); @@ -76,7 +57,6 @@ // Return final value int retVal = d(s1, s2); - cache->insert(lup, retVal); return retVal; }
