From: Peter Rabbitson Date: Wed, 24 Jun 2015 15:31:31 +0000 (+0200) Subject: Remove dependency on List::MoreUtils X-Git-Tag: v0.11022~46 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a1c9c64f601668626864d327aa076d9586b10c4b;p=dbsrgits%2FSQL-Translator.git Remove dependency on List::MoreUtils Current LMU maintainer was proven unresponsive to concerns about the towering complexity of that modules dependency chain. Use a pure-perl implementation of uniq() compatible with the version in LMU 0.4xx series The slowdown, while noticeable, is of no consequence to the larger codebase ~$ dd if=/dev/urandom bs=512 count=1 2>/dev/null | perl -0777 -Ilib -MSQL::Translator::Utils -MList::MoreUtils::XS -MBenchmark::Dumb -e ' my @list = map ord, split "", <>; Benchmark::Dumb::cmpthese( 0.0001 => { lmu => sub { List::MoreUtils::uniq(@list); }, pp => sub { SQL::Translator::Utils::uniq(@list); } }) ' Rate pp lmu pp 2838.17+-0.28/s -- -35.2% lmu 4381.99+-0.44/s 54.4% -- --- diff --git a/Changes b/Changes index a599229..b8c9bda 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,7 @@ Changes for SQL::Translator * Add support for monotonically increasing SQLite autoincs (GH#47) * Declare dependencies in deterministic order (RT#102859) + * Remove dependency on List::MoreUtils ( http://is.gd/lmu_cac_debacle ) 0.11021 2015-01-29 diff --git a/Makefile.PL b/Makefile.PL index 6b2fddd..9b2418a 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -18,7 +18,6 @@ my $deps = { 'Package::Variant' => '1.001001', 'Sub::Quote' => '0', 'Try::Tiny' => '0.04', - 'List::MoreUtils' => '0.09', 'Scalar::Util' => '0', }, recommends => { diff --git a/lib/SQL/Translator/Role/ListAttr.pm b/lib/SQL/Translator/Role/ListAttr.pm index 3a41569..fd40700 100644 --- a/lib/SQL/Translator/Role/ListAttr.pm +++ b/lib/SQL/Translator/Role/ListAttr.pm @@ -22,8 +22,7 @@ attributes. =cut -use SQL::Translator::Utils qw(parse_list_arg ex2err); -use List::MoreUtils qw(uniq); +use SQL::Translator::Utils qw(parse_list_arg ex2err uniq); use Sub::Quote qw(quote_sub); use Package::Variant ( diff --git a/lib/SQL/Translator/Schema/Trigger.pm b/lib/SQL/Translator/Schema/Trigger.pm index 8db8b5f..d915e59 100644 --- a/lib/SQL/Translator/Schema/Trigger.pm +++ b/lib/SQL/Translator/Schema/Trigger.pm @@ -29,9 +29,8 @@ C is the trigger object. =cut use Moo; -use SQL::Translator::Utils qw(parse_list_arg ex2err throw); +use SQL::Translator::Utils qw(parse_list_arg ex2err throw uniq); use SQL::Translator::Types qw(schema_obj enum); -use List::MoreUtils qw(uniq); use Sub::Quote qw(quote_sub); extends 'SQL::Translator::Schema::Object'; diff --git a/lib/SQL/Translator/Utils.pm b/lib/SQL/Translator/Utils.pm index d0ac9cc..ccc7ad3 100644 --- a/lib/SQL/Translator/Utils.pm +++ b/lib/SQL/Translator/Utils.pm @@ -16,7 +16,7 @@ our @EXPORT_OK = qw( debug normalize_name header_comment parse_list_arg truncate_id_uniquely $DEFAULT_COMMENT parse_mysql_version parse_dbms_version ddl_parser_instance batch_alter_table_statements - throw ex2err carp_ro + uniq throw ex2err carp_ro normalize_quote_options ); use constant COLLISION_TAG_LENGTH => 8; @@ -366,6 +366,15 @@ sub _find_co_root { } } +sub uniq { + my( %seen, $seen_undef, $numeric_preserving_copy ); + grep { not ( + defined $_ + ? $seen{ $numeric_preserving_copy = $_ }++ + : $seen_undef++ + ) } @_; +} + sub throw { die SQL::Translator::Utils::Error->new($_[0]); }