From: Shawn M Moore <sartak@gmail.com>
Date: Tue, 15 Jul 2008 03:11:53 +0000 (+0000)
Subject: Factor out a concatenation in grabbing the instance.
X-Git-Tag: 0.05~16
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e1bb560144e7ec7173ab5196f661a3b629323300;p=gitmo%2FMooseX-ClassAttribute.git

Factor out a concatenation in grabbing the instance.
In a profile of my app that uses this, this small function took up more time than any other function, because it's called so damn often.
---

diff --git a/lib/MooseX/ClassAttribute.pm b/lib/MooseX/ClassAttribute.pm
index 42eefa4..7306caf 100644
--- a/lib/MooseX/ClassAttribute.pm
+++ b/lib/MooseX/ClassAttribute.pm
@@ -69,10 +69,11 @@ sub process_class_attribute ## no critic RequireArgUnpacking
             unless grep { $_->isa('Moose::Object') } @parents;
 
         my $container_pkg = 'MooseX::ClassAttribute::Container::' . $caller;
+        my $instance_holder = $container_pkg . '::Self';
 
         my $instance_meth = sub {
             no strict 'refs'; ## no critic ProhibitNoStrict
-            return ${ $container_pkg . '::Self' } ||= shift->new(@_);
+            return $$instance_holder ||= shift->new(@_);
         };
 
         my $class =