From: Jesse Luehrs Date: Sat, 17 Sep 2011 19:15:57 +0000 (-0500) Subject: starting from the deepest tc isn't necessary X-Git-Tag: 2.0300~38 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMoose.git;a=commitdiff_plain;h=db730b319a4c487382b61d62e5fb0915a82a1bcd starting from the deepest tc isn't necessary --- diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index f5dd147..2b56617 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -420,11 +420,6 @@ sub _collect_all_parents { return @parents; } -sub _ancestor_count { - my $self = shift; - return scalar $self->_collect_all_parents; -} - sub create_child_type { my ($self, %opts) = @_; my $class = ref $self; diff --git a/lib/Moose/Meta/TypeConstraint/Union.pm b/lib/Moose/Meta/TypeConstraint/Union.pm index 410c622..befc557 100644 --- a/lib/Moose/Meta/TypeConstraint/Union.pm +++ b/lib/Moose/Meta/TypeConstraint/Union.pm @@ -131,13 +131,10 @@ sub equals { sub parent { my $self = shift; - my @tcs = @{ $self->type_constraints }; + my ($first, @rest) = @{ $self->type_constraints }; - my $deepest - = ( sort { $a->_ancestor_count <=> $b->_ancestor_count } @tcs )[-1]; - - for my $parent ( $deepest->_collect_all_parents ) { - return $parent if all { $_->is_a_type_of($parent) } @tcs; + for my $parent ( $first->_collect_all_parents ) { + return $parent if all { $_->is_a_type_of($parent) } @rest; } }