Commit 755ce7c3 authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

In get_all_alternative_translations():

  We know that fetch_all_by_Transcript() (on a TranslationAdaptor) will
  return a list of translations, where the first one will always be the
  canonical translation (if there is one).  Make use of this fact to
  make the routine slightly quicker.
parent f8abbac7
......@@ -625,11 +625,7 @@ sub translation {
sub get_all_alternative_translations {
my ($self) = @_;
my $canonical_translation = $self->translation();
if ( !defined($canonical_translation) ) { return [] }
if ( !defined( $self->{'alternative_translations'} ) ) {
if ( !exists( $self->{'alternative_translations'} ) ) {
if ( !defined( $self->adaptor() ) ) {
throw("No adaptor attached");
}
......@@ -637,22 +633,15 @@ sub get_all_alternative_translations {
my $pa = $self->adaptor()->db()->get_TranslationAdaptor();
my @translations = @{ $pa->fetch_all_by_Transcript($self) };
$self->{'alternative_translations'} = [];
foreach my $translation (@translations) {
if (
$translation->stable_id() eq $canonical_translation->stable_id()
)
{
next;
}
# The first in the list of translations is the canonical one,
# shift it off.
shift(@translations);
push( @{ $self->{'alternative_translations'} }, $translation );
}
$self->{'alternative_translations'} = \@translations;
}
return $self->{'alternative_translations'};
} ## end sub get_all_alternative_translations
}
=head2 add_alternative_translation
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment