func (v *View) Prepend(data []byte) {
	// Is there any space in the first buffer?
	if buf := v.data.Front(); buf != nil && buf.read > 0 {
		// Fill up before the first write.
		avail := buf.read
		copy(buf.data[0:], data[len(data)-avail:])
		data = data[:len(data)-avail]
		v.size += int64(avail)
	}

	for len(data) > 0 {
		// Do we need an empty buffer?
		buf := bufferPool.Get().(*Buffer)
		v.data.PushFront(buf)

		// The buffer is empty; copy last chunk.
		start := len(data) - len(buf.data)
		if start < 0 {
			start = 0 // Everything.
		}

		// We have to put the data at the end of the current
		// buffer in order to ensure that the next prepend will
		// correctly fill up the beginning of this buffer.
		bStart := len(buf.data) - len(data[start:])
		n := copy(buf.data[bStart:], data[start:])
		buf.read = bStart
		buf.write = len(buf.data)
		data = data[:start]
		v.size += int64(n)
	}
}
// Prepend prepends the given data.
Prepend prepends the given data.
// Prepend prepends the given data .
func (v *View) Prepend(data []byte) {
	if buf := v.data.Front(); buf != nil && buf.read > 0 {
		avail := buf.read
		copy(buf.data[0:], data[len(data)-avail:])
		data = data[:len(data)-avail]
		v.size += int64(avail)
	}
	for len(data) > 0 {
		buf := bufferPool.Get().(*Buffer)
		v.data.PushFront(buf)
		start := len(data) - len(buf.data)
		if start < 0 {
			start = 0 
		}
		bStart := len(buf.data) - len(data[start:])
		n := copy(buf.data[bStart:], data[start:])
		buf.read = bStart
		buf.write = len(buf.data)
		data = data[:start]
		v.size += int64(n)
	}
}
func ( v * View ) Prepend ( data [ ] byte ) { if buf := v . data . Front ( ) ; buf != nil && buf . read > 0 { avail := buf . read copy ( buf . data [ 0 : ] , data [ len ( data ) - avail : ] ) data = data [ : len ( data ) - avail ] v . size += int64 ( avail ) } for len ( data ) > 0 { buf := bufferPool . Get ( ) . ( * Buffer ) v . data . PushFront ( buf ) start := len ( data ) - len ( buf . data ) if start < 0 { start = 0 } bStart := len ( buf . data ) - len ( data [ start : ] ) n := copy ( buf . data [ bStart : ] , data [ start : ] ) buf . read = bStart buf . write = len ( buf . data ) data = data [ : start ] v . size += int64 ( n ) } }
Prepend prepends the given data.
Prepend prepends the given data .
// Is there any space in the first buffer? // Fill up before the first write. // Do we need an empty buffer? // The buffer is empty; copy last chunk. // Everything. // We have to put the data at the end of the current // buffer in order to ensure that the next prepend will // correctly fill up the beginning of this buffer.