void c4_Differ::AddEntry(t4_i32 off_, t4_i32 len_, const c4_Bytes &data_) { int n = _temp.GetSize(); _temp.SetSize(n + 1); c4_RowRef r = _temp[n]; pKeep(r) = (t4_i32)off_; pResize(r) = (t4_i32)len_; pBytes(r).SetData(data_); }
void c4_Differ::CreateDiff(int id_, c4_Column &col_) { _temp.SetSize(0); #if 0 t4_i32 offset = 0; t4_i32 savedOff = 0; t4_i32 savedLen = 0; c4_Strategy *strat = col_.Persist() != 0 ? &col_.Strategy(): 0; c4_ColIter iter(col_, 0, col_.ColSize()); while (iter.Next()) { const t4_byte *p = iter.BufLoad(); if (strat != 0 && strat->_mapStart != 0 && p >= strat->_mapStart && p - strat->_mapStart < strat->_dataSize) { t4_i32 nextOff = p - strat->_mapStart; if (savedLen == 0) savedOff = nextOff; if (nextOff == savedOff + savedLen) { savedLen += iter.BufLen(); continue; } if (savedLen > 0) AddEntry(savedOff, savedLen, c4_Bytes()); savedOff = nextOff; savedLen = iter.BufLen(); } else { AddEntry(savedOff, savedLen, c4_Bytes(p, iter.BufLen())); savedLen = 0; } offset += iter.BufLen(); } c4_View diff = pDiff(_diffs[id_]); if (_temp.GetSize() != diff.GetSize() || _temp != diff) #else c4_Bytes t1; const t4_byte *p = col_.FetchBytes(0, col_.ColSize(), t1, false); AddEntry(0, 0, c4_Bytes(p, col_.ColSize())); #endif pDiff(_diffs[id_]) = _temp; pOrig(_diffs[id_]) = col_.Position(); }
int c4_Differ::NewDiffID() { int n = _diffs.GetSize(); _diffs.SetSize(n + 1); return n; }