MCPcopy Index your code
hub / github.com/kovidgoyal/kitty / read_next

Method read_next

tools/rsync/algorithm.go:533–569  ·  view source on GitHub ↗

See https://rsync.samba.org/tech_report/node4.html for the design of this algorithm

()

Source from the content-addressed store, hash-verified

531
532// See https://rsync.samba.org/tech_report/node4.html for the design of this algorithm
533func (self *diff) read_next() (err error) {
534 if self.window.sz > 0 {
535 if ok, err := self.ensure_idx_valid(self.window.pos + self.window.sz); !ok {
536 if err != nil {
537 return err
538 }
539 return self.finish_up()
540 }
541 self.window.pos++
542 self.data.sz++
543 self.rc.add_one_byte(self.buffer[self.window.pos], self.buffer[self.window.pos+self.window.sz-1])
544 } else {
545 if ok, err := self.ensure_idx_valid(self.window.pos + self.block_size - 1); !ok {
546 if err != nil {
547 return err
548 }
549 return self.finish_up()
550 }
551 self.window.sz = self.block_size
552 self.rc.full(self.buffer[self.window.pos : self.window.pos+self.window.sz])
553 }
554 found_hash := false
555 var block_index uint64
556 if hh, ok := self.hash_lookup[self.rc.val]; ok {
557 block_index, found_hash = find_hash(hh, self.hash(self.buffer[self.window.pos:self.window.pos+self.window.sz]))
558 }
559 if found_hash {
560 if err = self.send_data(); err != nil {
561 return
562 }
563 self.enqueue(Operation{Type: OpBlock, BlockIndex: block_index})
564 self.window.pos += self.window.sz
565 self.data.pos = self.window.pos
566 self.window.sz = 0
567 }
568 return nil
569}
570
571type OperationWriter struct {
572 Operations []Operation

Callers 1

pump_till_op_writtenMethod · 0.95

Calls 8

ensure_idx_validMethod · 0.95
finish_upMethod · 0.95
hashMethod · 0.95
send_dataMethod · 0.95
enqueueMethod · 0.95
find_hashFunction · 0.85
add_one_byteMethod · 0.80
fullMethod · 0.80

Tested by

no test coverage detected