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

Method Bytes

internal/buffer/line_array.go:172–186  ·  view source on GitHub ↗

Bytes returns the string that should be written to disk when the line array is saved

()

Source from the content-addressed store, hash-verified

170// Bytes returns the string that should be written to disk when
171// the line array is saved
172func (la *LineArray) Bytes() []byte {
173 b := new(bytes.Buffer)
174 // initsize should provide a good estimate
175 b.Grow(int(la.initsize + 4096))
176 for i, l := range la.lines {
177 b.Write(l.data)
178 if i != len(la.lines)-1 {
179 if la.Endings == FFDos {
180 b.WriteByte('\r')
181 }
182 b.WriteByte('\n')
183 }
184 }
185 return b.Bytes()
186}
187
188// newlineBelow adds a newline below the given line number
189func (la *LineArray) newlineBelow(y int) {

Callers 10

ApplyDiffMethod · 0.80
SerializeMethod · 0.80
checkFunction · 0.80
benchReadFunction · 0.80
TestJoinFunction · 0.80
TestRemoveFunction · 0.80
FiniMethod · 0.80
updateDiffMethod · 0.80
SaveHistoryMethod · 0.80
GetMemStatsFunction · 0.80

Calls 1

WriteMethod · 0.45

Tested by 4

checkFunction · 0.64
benchReadFunction · 0.64
TestJoinFunction · 0.64
TestRemoveFunction · 0.64