class RSpec::Core::Formatters::ExceptionPresenter::Factory::CommonBacktraceTruncater

@private

def initialize(parent)

def initialize(parent)
  @parent = parent
end

def with_truncated_backtrace(child)

def with_truncated_backtrace(child)
  child_bt  = child.backtrace
  parent_bt = @parent.backtrace
  return child if child_bt.nil? || child_bt.empty? || parent_bt.nil?
  index_before_first_common_frame = -1.downto(-child_bt.size).find do |index|
    parent_bt[index] != child_bt[index]
  end
  return child if index_before_first_common_frame == -1
  child = child.dup
  child.set_backtrace(child_bt[0..index_before_first_common_frame])
  child
end