From 4096510d05b5bb8eb68b046561ceaa336abe2966 Mon Sep 17 00:00:00 2001 From: Pragmatic Software Date: Fri, 27 Aug 2021 19:57:18 -0700 Subject: [PATCH] Replace Text::Levenshtein with Text::Levenshtein::XS Existing PBot users: please run `cpanm Text::Levenshtein::XS` to install this module. --- lib/PBot/Core/MessageHistory/Storage/SQLite.pm | 16 ++++++++-------- lib/PBot/Core/NickList.pm | 4 ++-- lib/PBot/VERSION.pm | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/PBot/Core/MessageHistory/Storage/SQLite.pm b/lib/PBot/Core/MessageHistory/Storage/SQLite.pm index 6a1c50df..b2eeacfe 100644 --- a/lib/PBot/Core/MessageHistory/Storage/SQLite.pm +++ b/lib/PBot/Core/MessageHistory/Storage/SQLite.pm @@ -20,10 +20,10 @@ use PBot::Core::Utils::SQLiteLogger; use PBot::Core::Utils::SQLiteLoggerLayer; use DBI; -use Carp qw/shortmess/; -use Time::HiRes qw/time/; +use Carp qw/shortmess/; +use Time::HiRes qw/time/; use Text::CSV; -use Text::Levenshtein qw/fastdistance/; +use Text::Levenshtein::XS qw/distance/; use Time::Duration; sub initialize { @@ -537,7 +537,7 @@ sub get_message_account { } # fuzzy match hosts - my $distance = fastdistance($host, $thost); + my $distance = distance($host, $thost); my $length = (length($host) > length($thost)) ? length $host : length $thost; #$self->{pbot}->{logger}->log("distance: " . ($distance / $length) . " -- $host vs $thost\n") if $length != 0; @@ -671,7 +671,7 @@ sub get_message_account { } } - my $distance = fastdistance($host, $thost); + my $distance = distance($host, $thost); my $length = (length($host) > length($thost)) ? length $host : length $thost; #$self->{pbot}->{logger}->log("distance: " . ($distance / $length) . " -- $host vs $thost\n") if $length != 0; @@ -745,7 +745,7 @@ sub get_message_account { my ($nick1) = $host1 =~ m/^([^!]+)!/; my ($nick2) = $host2 =~ m/^([^!]+)!/; - my $distance = fastdistance($nick1, $nick2); + my $distance = distance($nick1, $nick2); my $length = (length $nick1 > length $nick2) ? length $nick1 : length $nick2; my $irc_cloak = $self->{pbot}->{registry}->get_value('irc', 'cloak') // 'user'; @@ -1486,7 +1486,7 @@ sub link_aliases { } } - my $distance = fastdistance($host, $thost); + my $distance = distance($host, $thost); my $length = (length($host) > length($thost)) ? length $host : length $thost; #$self->{pbot}->{logger}->log("distance: " . ($distance / $length) . " -- $host vs $thost\n") if $length != 0; @@ -1589,7 +1589,7 @@ sub link_alias { $host2 = lc $host2; my ($nick1) = $host1 =~ m/^([^!]+)!/; my ($nick2) = $host2 =~ m/^([^!]+)!/; - my $distance = fastdistance($nick1, $nick2); + my $distance = distance($nick1, $nick2); my $length = (length $nick1 > length $nick2) ? length $nick1 : length $nick2; my $irc_cloak = $self->{pbot}->{registry}->get_value('irc', 'cloak') // 'user'; if ($distance > 1 && ($nick1 !~ /^guest/ && $nick2 !~ /^guest/) && ($host1 !~ /$irc_cloak/ || $host2 !~ /$irc_cloak/)) { diff --git a/lib/PBot/Core/NickList.pm b/lib/PBot/Core/NickList.pm index 6928b40b..da653cbb 100644 --- a/lib/PBot/Core/NickList.pm +++ b/lib/PBot/Core/NickList.pm @@ -12,7 +12,7 @@ use parent 'PBot::Core::Class'; use PBot::Imports; -use Text::Levenshtein qw/fastdistance/; +use Text::Levenshtein::XS qw/distance/; use Time::HiRes qw/gettimeofday/; sub initialize { @@ -217,7 +217,7 @@ sub is_present_similar { return 0; } - my $distance = fastdistance($nick, $person); + my $distance = distance($nick, $person); my $length = length $nick > length $person ? length $nick : length $person; if ($length != 0 && $distance / $length <= $percentage) { diff --git a/lib/PBot/VERSION.pm b/lib/PBot/VERSION.pm index 3034eeb6..e9857313 100644 --- a/lib/PBot/VERSION.pm +++ b/lib/PBot/VERSION.pm @@ -25,7 +25,7 @@ use PBot::Imports; # These are set by the /misc/update_version script use constant { BUILD_NAME => "PBot", - BUILD_REVISION => 4371, + BUILD_REVISION => 4372, BUILD_DATE => "2021-08-27", };