mirror of
https://github.com/vcmi/vcmi.git
synced 2025-08-10 22:31:40 +02:00
optimize textSearchSimilar
This commit is contained in:
@@ -307,7 +307,10 @@ bool TextOperations::textSearchSimilar(const std::string & s, const std::string
|
|||||||
if(boost::algorithm::contains(haystack, needle))
|
if(boost::algorithm::contains(haystack, needle))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for(int i = 0; i < haystack.size() - needle.size(); i++)
|
if(needle.size() > haystack.size())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for(int i = 0; i < haystack.size() - needle.size() + 1; i++)
|
||||||
{
|
{
|
||||||
auto dist = getLevenshteinDistance(haystack.substr(i, needle.size()), needle);
|
auto dist = getLevenshteinDistance(haystack.substr(i, needle.size()), needle);
|
||||||
if(needle.size() > 2 && dist <= 1)
|
if(needle.size() > 2 && dist <= 1)
|
||||||
|
Reference in New Issue
Block a user