in reply to Re^2: Can I speed this up? (repetitively scanning ranges in a large array)
in thread Can I speed this up? (repetitively scanning ranges in a large array)

I didn't "inline" for performance reason, I didn't create a sub because there was no reason to.

my $dist = ($start - $end + 1) % $max_length;

is perfectly fine without transforming it into

my $dist = dist($start, $end); sub dist { my $start = shift // die; my $end = shift // die; if ( $end >= $start ) { # simple range return $end - $start + 1; } # warpped range return $max_length - $start + 1 + $end; }

This is what I was explaining earlier.