Commit 21f3692b authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent c21de4a4
......@@ -441,19 +441,32 @@ func (δBtail *ΔBtail) rebuild() (err error) {
δBtail.byRoot[root] = δTtail
}
// δTtail.vδT[i] <- merge δT*
δTi := δTtail.vδT[i]
// δTtail.vδT <- merge δT*
l := len(δTtail.vδT)
j := sort.Search(l, func(k int) bool {
return δZ.Rev <= δTtail.vδT[k].Rev
})
if j == l || δTtail.vδT[j].Rev != δZ.Rev {
δTcurr := ΔTree{Rev: δZ.Rev, ΔKV: map[Key]ΔValue{}}
// insert(@j, δTcurr)
δTtail.vδT = append(δTtail.vδT[:j],
append([]ΔTree{δTcurr},
δTtail.vδT[j:]...)...)
}
δTcurr := δTtail.vδT[j]
for k, δv := range δT {
// the diff was backward; δTtail entries are with diff forward
δv.New, δv.Old = δv.Old, δv.New
δv_, already := δTi.ΔKV[k]
δv_, already := δTcurr.ΔKV[k]
if already {
if δv != δv_ {
panicf("[%v] inconsistent δv:\nδTi: %v\nδT: %v", k, δTi, δT)
panicf("[%v] inconsistent δv:\nδTcurr: %v\nδT: %v", k, δTcurr, δT)
}
} else {
δTi.ΔKV[k] = δv
δTcurr.ΔKV[k] = δv
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment