Module: SimpleCov::Combine::InternedCounts

Extended by:
InternedCounts
Included in:
InternedCounts
Defined in:
lib/simplecov/combine/interned_counts.rb

Overview

The inner merge loop the branches and methods combiners share: folds source's tuple => count pairs into target, an interned table keyed by each tuple's merge identity and holding [raw_key, count] pairs. The first-seen raw key is kept for display; counts sum. target and its pairs are always built by this loop, so updating them in place can't reach data a caller still holds.

Instance Method Summary collapse

Instance Method Details

#absorb_counts(target, source, identities) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/simplecov/combine/interned_counts.rb', line 14

def absorb_counts(target, source, identities)
  source.each do |key, count|
    interned = identities[key]
    entry = target[interned]
    if entry
      entry[1] += count
    else
      target[interned] = [key, count]
    end
  end
  target
end