MCPcopy
hub / github.com/google/gvisor / MergeUnchecked

Method MergeUnchecked

pkg/segment/set.go:706–718  ·  view source on GitHub ↗

MergeUnchecked attempts to merge two neighboring segments. If successful, MergeUnchecked returns an iterator to the merged segment, and all existing iterators are invalidated. Otherwise, MergeUnchecked returns a terminal iterator. Precondition: first is the predecessor of second: first.NextSegment(

(first, second Iterator)

Source from the content-addressed store, hash-verified

704// Precondition: first is the predecessor of second: first.NextSegment() ==
705// second, first == second.PrevSegment().
706func (s *Set) MergeUnchecked(first, second Iterator) Iterator {
707 if first.End() == second.Start() {
708 if mval, ok := (Functions{}).Merge(first.Range(), first.Value(), second.Range(), second.Value()); ok {
709 // N.B. This must be unchecked because until s.Remove(second), first
710 // overlaps second.
711 first.SetEndUnchecked(second.End())
712 first.SetValue(mval)
713 // Remove will handle the maxGap update if necessary.
714 return s.Remove(second).PrevSegment()
715 }
716 }
717 return Iterator{}
718}
719
720// MergePrev attempts to merge the given segment with its predecessor if
721// possible, and returns an updated iterator to the extended segment. All

Callers 6

MergeMethod · 0.95
MergePrevMethod · 0.95
MergeNextMethod · 0.95
UnisolateMethod · 0.95
MergeAllMethod · 0.95
MergeInsideRangeMethod · 0.95

Calls 9

RemoveMethod · 0.95
SetEndUncheckedMethod · 0.80
StartMethod · 0.65
MergeMethod · 0.65
ValueMethod · 0.65
EndMethod · 0.45
RangeMethod · 0.45
SetValueMethod · 0.45
PrevSegmentMethod · 0.45

Tested by

no test coverage detected