From: Peter Rabbitson Date: Thu, 25 Nov 2010 00:48:43 +0000 (+0100) Subject: Microoptimization of the IC::DT registration code X-Git-Tag: v0.08125~41 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=bbe0a14d6df060f74123365d906fc16a4187d1ae Microoptimization of the IC::DT registration code --- diff --git a/lib/DBIx/Class/InflateColumn/DateTime.pm b/lib/DBIx/Class/InflateColumn/DateTime.pm index c35f151..7b7e144 100644 --- a/lib/DBIx/Class/InflateColumn/DateTime.pm +++ b/lib/DBIx/Class/InflateColumn/DateTime.pm @@ -112,21 +112,22 @@ sub register_column { $self->next::method($column, $info, @rest); - return unless defined($info->{data_type}); - my $requested_type; - for (qw/date datetime timestamp/) { + for (qw/datetime timestamp date/) { my $key = "inflate_${_}"; + if (exists $info->{$key}) { - next unless exists $info->{$key}; - - return if ! $info->{$key}; + # this bailout is intentional + return unless $info->{$key}; - $requested_type = $_; - last; + $requested_type = $_; + last; + } } - my $data_type = lc($info->{data_type} || ''); + return if (!$requested_type and !$info->{data_type}); + + my $data_type = lc( $info->{data_type} || '' ); # _ic_dt_method will follow whatever the registration requests # thus = instead of ||= @@ -142,11 +143,12 @@ sub register_column { elsif ($data_type =~ /^ (?: date | datetime | timestamp ) $/x) { $info->{_ic_dt_method} = $data_type; } - else { + elsif ($requested_type) { $info->{_ic_dt_method} = $requested_type; } - - return unless $info->{_ic_dt_method}; + else { + return; + } if ($info->{extra}) { for my $slot (qw/timezone locale floating_tz_ok/) {