From: Dagfinn Ilmari Mannsåker Date: Sat, 25 Apr 2015 17:01:03 +0000 (+0100) Subject: Simplify array_eq function X-Git-Tag: 0.07043~11 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d3a098216ed9aa7e7412e271146268bd23061cda;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Simplify array_eq function It's only ever used for names and has "eq" in the name, so there's no need to try and be clever about things that look like numbers. --- diff --git a/lib/DBIx/Class/Schema/Loader/Utils.pm b/lib/DBIx/Class/Schema/Loader/Utils.pm index f6315de..4fc5fb6 100644 --- a/lib/DBIx/Class/Schema/Loader/Utils.pm +++ b/lib/DBIx/Class/Schema/Loader/Utils.pm @@ -6,7 +6,7 @@ use warnings; use Test::More; use String::CamelCase 'wordsplit'; use Carp::Clan qw/^DBIx::Class/; -use Scalar::Util 'looks_like_number'; +use List::Util 'all'; use namespace::clean; use Exporter 'import'; use Data::Dumper (); @@ -198,19 +198,9 @@ sub write_file($$) { sub array_eq($$) { no warnings 'uninitialized'; - my ($a, $b) = @_; + my ($l, $r) = @_; - return unless @$a == @$b; - - for (my $i = 0; $i < @$a; $i++) { - if (looks_like_number $a->[$i]) { - return unless $a->[$i] == $b->[$i]; - } - else { - return unless $a->[$i] eq $b->[$i]; - } - } - return 1; + return @$l == @$r && all { $l->[$_] eq $r->[$_] } 0..$#$l; } 1;