MCPcopy
hub / github.com/micro-editor/micro / calcHash

Method calcHash

internal/buffer/buffer.go:164–181  ·  view source on GitHub ↗

calcHash calculates md5 hash of all lines in the buffer

(out *[md5.Size]byte)

Source from the content-addressed store, hash-verified

162
163// calcHash calculates md5 hash of all lines in the buffer
164func (b *SharedBuffer) calcHash(out *[md5.Size]byte) {
165 h := md5.New()
166
167 if len(b.lines) > 0 {
168 h.Write(b.lines[0].data)
169
170 for _, l := range b.lines[1:] {
171 if b.Endings == FFDos {
172 h.Write([]byte{'\r', '\n'})
173 } else {
174 h.Write([]byte{'\n'})
175 }
176 h.Write(l.data)
177 }
178 }
179
180 h.Sum((*out)[:0])
181}
182
183// MarkModified marks the buffer as modified for this frame
184// and performs rehighlighting if syntax highlighting is enabled

Callers 5

setModifiedMethod · 0.95
saveToFileMethod · 0.80
DoSetOptionNativeMethod · 0.80
NewBufferFunction · 0.80
ReOpenMethod · 0.80

Calls 1

WriteMethod · 0.45

Tested by

no test coverage detected