remove result_class stuff from load_namespaces, better to not do it than to do it...
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSet.pm
index c71043b..c94476d 100644 (file)
@@ -95,14 +95,24 @@ sub new {
 
   $attrs->{alias} ||= 'me';
 
-  bless {
+  # XXXX
+  # Use a named hash here and bless afterwards to avoid a huge performance hit
+  # in perl 5.8.8-5+ FC5 and later, and possibly other distributions.
+  #
+  # See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=196836 for more
+  # information.
+  my $self = {
     result_source => $source,
     result_class => $attrs->{result_class} || $source->result_class,
     cond => $attrs->{where},
     count => undef,
     pager => undef,
     attrs => $attrs
-  }, $class;
+  };
+
+  bless $self, $class;
+
+  return $self;
 }
 
 =head2 search
@@ -1550,11 +1560,13 @@ sub _resolved_attrs {
 
   my $collapse = $attrs->{collapse} || {};
   if (my $prefetch = delete $attrs->{prefetch}) {
+    $prefetch = $self->_merge_attr({}, $prefetch);
     my @pre_order;
+    my $seen = $attrs->{seen_join} || {};
     foreach my $p (ref $prefetch eq 'ARRAY' ? @$prefetch : ($prefetch)) {
       # bring joins back to level of current class
       my @prefetch = $source->resolve_prefetch(
-        $p, $alias, { %{$attrs->{seen_join}||{}} }, \@pre_order, $collapse
+        $p, $alias, $seen, \@pre_order, $collapse
       );
       push(@{$attrs->{select}}, map { $_->[0] } @prefetch);
       push(@{$attrs->{as}}, map { $_->[1] } @prefetch);