7D7CMNN3DJ5FINFJGQVZXF5X2MYOZHXW3I4RFASPX5SKNTR44WNQC
func (g *Graph) blockContaining(change Hash, pos ChangePosition) *Block {
func (g *Graph) blockStarting(change Hash, pos ChangePosition) *Block {
blocks := g.Index[change]
if len(blocks) == 0 {
return nil
}
i := sort.Search(len(blocks), func(i int) bool {
return blocks[i].Start >= pos
})
if i == len(blocks) {
return nil
}
if blocks[i].Start == pos {
return blocks[i]
}
// TODO: split blocks
return nil
}
// blockEnding returns the block ending at the specified location, or nil if
// it is not found.
func (g *Graph) blockEnding(change Hash, pos ChangePosition) *Block {
return nil
if blocks[i].Start >= pos {
return nil
}
// Split the block.
oldBlock := blocks[i]
newBlock := &Block{
Change: change,
Start: pos,
End: oldBlock.End,
Content: oldBlock.Content[pos-oldBlock.Start:],
Edges: oldBlock.Edges,
}
oldBlock.End = pos
oldBlock.Content = oldBlock.Content[:pos-oldBlock.Start]
oldBlock.Edges = nil
makeEdge(change, EdgeFlagsBlock, oldBlock, newBlock)
blocks = append(blocks, newBlock)
sort.Sort(blockList(blocks))
g.Index[change] = blocks
return oldBlock
func (e Edit) atoms() []Atom {
return []Atom{e.Change}
}
func edit(data []byte) ([]byte, Edit, error) {
var e Edit
data, _, err := tuple(
assign(&e.Change, atom),
assign(&e.Local, local),
assign(&e.Encoding, mapValue(option(toString(lengthData(uint64LE))), func(p *string) string {
if p == nil {
return ""
}
return *p
})),
)(data)
return data, e, err
}