import "github.com/benburkert/padded"
Package padded provides a padded byte slice and pool allocator.
type Pool struct {
// contains filtered or unexported fields
}
Pool implements a memory pool for padded byte slices. Both the capacity and padding are reclaimed when a slice is freed.
Free returns a Slice to p for future reallocation.
Make allocates (or reallocates) a Slice for the len, cap, and pad.
Slice is a padded byte slice. The padding is a scratch space allocated in front of byte slice and behaves roughly the same as the capacity. The len & cap built-in funcs work the same for Slice as for []byte, but append does not. Use the Append method instead.
Prepending elements to the slice fills in the padding, just as appending elements to the slice fills in the capacity. The elements must be naturally aligned to fill in the scratch padding, otherwise an append is performed. The word size on an amd64 machine is 8 bytes, so element bytes should be prepended in multiples of 8.
Make allocates and initializes a padded byte slice. Unlike cap, the pad value is only the size of the scratch space in front of the slice. (The scratch space in back is cap - len.)
The allocated scratch space for padding may be >= pad.
Append appends elements to the end of s. The behavior of Append is the same as the built-in append function.
Pad returns the length of the remaining bytes of padding.
Prepend concatenates elems onto the beginning of s.
Package padded imports 4 packages (graph). Updated 2020-08-16. Refresh now. Tools for package owners.