Skip to content

Commit

Permalink
>10% performance improvement seems worthwhile (#7869)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedsharpe committed Jun 3, 2022
1 parent 6c6db6e commit 844789f
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,13 @@ public PQContext( final Iterator<F> iterator,

public static final class PQEntry<F extends Feature> implements Comparable<PQEntry<F>> {
private final PQContext<F> context;
private final int contigIndex;
private final F feature;

public PQEntry( final PQContext<F> context, final F feature ) {
this.context = context;
this.feature = feature;
this.contigIndex = context.getDictionary().getSequenceIndex(feature.getContig());
}

public PQContext<F> getContext() { return context; }
Expand All @@ -287,7 +289,14 @@ public PQEntry( final PQContext<F> context, final F feature ) {

@Override
public int compareTo( PQEntry<F> entry ) {
return IntervalUtils.compareLocatables(feature, entry.getFeature(), context.getDictionary());
int result = Integer.compare(contigIndex, entry.contigIndex);
if ( result == 0 ) {
result = Integer.compare(feature.getStart(), entry.feature.getStart());
if ( result == 0 ) {
result = Integer.compare(feature.getEnd(), entry.feature.getEnd());
}
}
return result;
}
}
}

0 comments on commit 844789f

Please sign in to comment.