class SourceMap::Map

def bsearch(offset, from = 0, to = size - 1)

def bsearch(offset, from = 0, to = size - 1)
  mid = (from + to) / 2
  # We haven't found a match
  if from > to
    return from < 1 ? nil : self[from-1]
  end
  # We found an exact match
  if offset == self[mid].generated
    self[mid]
  # We need to filter more
  elsif offset < self[mid].generated
    bsearch(offset, from, mid - 1)
  elsif offset > self[mid].generated
    bsearch(offset, mid + 1, to)
  end
end