From: Peter Rabbitson Date: Sun, 12 Oct 2014 10:23:10 +0000 (+0200) Subject: Stop lazy-requiring B and Storable in internal functions X-Git-Tag: v0.082820~24 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=14ae8b98c0977dde9757fa771f437a614c106a8c;p=dbsrgits%2FDBIx-Class.git Stop lazy-requiring B and Storable in internal functions Almost every non-toy program will end up lazy-loading these anyway, so move their require to compile time. This also helps with load-patterns changing in SQLA and Moo, and failing lean_startup.t on some smokers (cherry pick of d7d45bdc) --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index a9b312b..d04a24c 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -1213,7 +1213,6 @@ reference to any schema, so are rather useless. sub thaw { my ($self, $obj) = @_; local $DBIx::Class::ResultSourceHandle::thaw_schema = $self; - require Storable; return Storable::thaw($obj); } @@ -1225,7 +1224,6 @@ it is just provided here for symmetry. =cut sub freeze { - require Storable; return Storable::nfreeze($_[1]); } @@ -1248,7 +1246,6 @@ objects so their references to the schema object sub dclone { my ($self, $obj) = @_; local $DBIx::Class::ResultSourceHandle::thaw_schema = $self; - require Storable; return Storable::dclone($obj); } diff --git a/lib/DBIx/Class/_Util.pm b/lib/DBIx/Class/_Util.pm index c11ee22..c1cb5ef 100644 --- a/lib/DBIx/Class/_Util.pm +++ b/lib/DBIx/Class/_Util.pm @@ -55,7 +55,9 @@ BEGIN { # Carp::Skip to the rescue soon use DBIx::Class::Carp '^DBIx::Class|^DBICTest'; +use B (); use Carp 'croak'; +use Storable 'nfreeze'; use Scalar::Util qw(weaken blessed reftype); use List::Util qw(first); use Sub::Quote qw(qsub quote_sub); @@ -100,16 +102,14 @@ sub refdesc ($) { sub refcount ($) { croak "Expecting a reference" if ! length ref $_[0]; - require B; # No tempvars - must operate on $_[0], otherwise the pad # will count as an extra ref B::svref_2object($_[0])->REFCNT; } sub serialize ($) { - require Storable; local $Storable::canonical = 1; - Storable::nfreeze($_[0]); + nfreeze($_[0]); } sub is_exception ($) { diff --git a/t/53lean_startup.t b/t/53lean_startup.t index 5e417d3..072f585 100644 --- a/t/53lean_startup.t +++ b/t/53lean_startup.t @@ -107,6 +107,7 @@ BEGIN { Scalar::Util List::Util + Storable Class::Accessor::Grouped Class::C3::Componentised