From e6f88fbc5fedb96400a000336bbf41b694e0176a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Kusalananda=20K=C3=A4h=C3=A4ri?= <ak4@sanger.ac.uk> Date: Tue, 24 Aug 2010 10:18:59 +0000 Subject: [PATCH] In equals(): If the argument is the same as $self, return true at once. --- modules/Bio/EnsEMBL/Exon.pm | 10 ++++++---- modules/Bio/EnsEMBL/Gene.pm | 2 ++ modules/Bio/EnsEMBL/Transcript.pm | 2 ++ 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/Bio/EnsEMBL/Exon.pm b/modules/Bio/EnsEMBL/Exon.pm index 890510c1e0..11f663d0f5 100755 --- a/modules/Bio/EnsEMBL/Exon.pm +++ b/modules/Bio/EnsEMBL/Exon.pm @@ -815,12 +815,14 @@ sub slice { =cut sub equals { - my ($self, $exon) = @_; + my ( $self, $exon ) = @_; - assert_ref($exon, 'Bio::EnsEMBL::Exon'); + if ( $self eq $exon ) { return 1 } + + assert_ref( $exon, 'Bio::EnsEMBL::Exon' ); my $feature_equals = $self->SUPER::equals($exon); - if (defined($feature_equals) && $feature_equals == 0) { + if ( defined($feature_equals) && $feature_equals == 0 ) { return 0; } @@ -842,7 +844,7 @@ sub equals { } return 0; -} +} ## end sub equals =head2 move diff --git a/modules/Bio/EnsEMBL/Gene.pm b/modules/Bio/EnsEMBL/Gene.pm index 56900713bb..7ac54b8edd 100755 --- a/modules/Bio/EnsEMBL/Gene.pm +++ b/modules/Bio/EnsEMBL/Gene.pm @@ -380,6 +380,8 @@ sub description { sub equals { my ( $self, $gene ) = @_; + if ( $self eq $gene ) { return 1 } + assert_ref( $gene, 'Bio::EnsEMBL::Gene' ); my $feature_equals = $self->SUPER::equals($gene); diff --git a/modules/Bio/EnsEMBL/Transcript.pm b/modules/Bio/EnsEMBL/Transcript.pm index 59f8b198a6..18a717d774 100755 --- a/modules/Bio/EnsEMBL/Transcript.pm +++ b/modules/Bio/EnsEMBL/Transcript.pm @@ -1956,6 +1956,8 @@ sub swap_exons { sub equals { my ( $self, $transcript ) = @_; + if ( $self eq $transcript ) { return 1 } + assert_ref( $transcript, 'Bio::EnsEMBL::Transcript' ); my $feature_equals = $self->SUPER::equals($transcript); -- GitLab