<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Jul 6, 2012, at 3:40 PM, Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="font-family: Optima; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; ">I still think we should likely make join() use this code because we should make it handle that input pattern efficiently, but fall back on something that isn't super-linear when it hits edge cases.</div></blockquote><div><br></div><div>How about sticking the merge state in a (local) class:</div><div><br></div><div>class LIMerger {</div><div>  NewRanges, …</div><div>public:</div><div>  LIMerger(LiveInterval &LHS, SlotIndex StartPos);</div><div>  void add(SlotIndex From, SlotIndex To, VNInfo *VNI);</div><div>  void finish();</div><div>};</div><div><br></div><div>That interface could readily be used by all three clients, and you don't clutter up the code with value mapping stuff.</div><div><br></div><div>The add method can require disjoint, increasing segments:</div><div><br></div><div>void add(…) {</div><div>  assert(From >= StartPos);</div><div>  StartPos = To;</div><div>…</div><div>}</div><div><br></div><div>/jakob</div><div><br></div></div></body></html>