seen records that h has now been seen and reports whether it was seen before. When seen returns false, the caller is expected to print a report for h.
(h uint64)
| 762 | // seen records that h has now been seen and reports whether it was seen before. |
| 763 | // When seen returns false, the caller is expected to print a report for h. |
| 764 | func (d *dedup) seen(h uint64) bool { |
| 765 | d.mu.Lock() |
| 766 | if d.m == nil { |
| 767 | d.m = make(map[uint64]bool) |
| 768 | } |
| 769 | seen := d.m[h] |
| 770 | d.m[h] = true |
| 771 | d.mu.Unlock() |
| 772 | return seen |
| 773 | } |
| 774 | |
| 775 | // seenLossy is a variant of seen that avoids a lock by using a cache of recently seen hashes. |
| 776 | // Each cache entry is N-way set-associative: h can appear in any of the slots. |