Skip to content
Snippets Groups Projects
Commit 8b440d4f authored by Andreas Kusalananda Kähäri's avatar Andreas Kusalananda Kähäri
Browse files

Change to overlap_size():

  The ranges in the registry are sorted by start position.  When
  calculating the overlap with a query range, a loop goes through the
  registered ranges and checks for overlaps between each range and the
  query.  This change will terminate this loop when all the remaining
  start positions are larger than the end position of the query range.

  This cuts the running time for this routine by 90% in some
  applications that registers a large number of ranges.

Tested.
parent d5ed5250
No related branches found
No related tags found
No related merge requests found
......@@ -323,6 +323,13 @@ sub overlap_size {
for($CUR=$start_idx; $CUR < $len; $CUR++) {
my ($pstart,$pend) = @{$list->[$CUR]};
if ( $pstart > $end ) {
# The rest of the ranges in the registry are out of range of what
# we're looking for (they start after the end of our query range),
# so don't look further.
last;
}
#no work needs to be done at all if
#if we find a range pair that entirely overlaps the requested region
if($pstart <= $start && $pend >= $end) {
......
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