Range

The min and max method of Range are replaced for performance reasons.

Summary
RangeThe min and max method of Range are replaced for performance reasons.
Functions
minFor performance reasons a specialised method for integers is added.
maxFor performance reasons a specialised method for integers is added.
sizeCompute the size of a range.

Functions

min

def min

For performance reasons a specialised method for integers is added.

def min
  if Integer === self.begin
    self.begin
  else
    orig_min
  end
end

max

def max

For performance reasons a specialised method for integers is added.

def max
  if Integer === self.end
    exclude_end? ? self.end - 1 : self.end
  else
    orig_max
  end
end

size

def size

Compute the size of a range.

def size
  max + 1 - min
end
def min
For performance reasons a specialised method for integers is added.
def max
For performance reasons a specialised method for integers is added.
def size
Compute the size of a range.
Close