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

Function Append

internal/buffer/line_array.go:83–95  ·  view source on GitHub ↗

Append efficiently appends lines together It allocates an additional 10000 lines if the original estimate is incorrect

(slice []Line, data ...Line)

Source from the content-addressed store, hash-verified

81// It allocates an additional 10000 lines if the original estimate
82// is incorrect
83func Append(slice []Line, data ...Line) []Line {
84 l := len(slice)
85 if l+len(data) > cap(slice) { // reallocate
86 newSlice := make([]Line, (l+len(data))+10000)
87 copy(newSlice, slice)
88 slice = newSlice
89 }
90 slice = slice[0 : l+len(data)]
91 for i, c := range data {
92 slice[l+i] = c
93 }
94 return slice
95}
96
97// NewLineArray returns a new line array from an array of bytes
98func NewLineArray(size uint64, endings FileFormat, reader io.Reader) *LineArray {

Callers 1

NewLineArrayFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected