Optimize set_tip_to()

Split from #2352, start of a new PR chain.