Back to godoc.org

Package xbytes

v0.0.0-...-3cf7f3f
Latest Go to latest

The latest major version is .

Published: May 27, 2020 | License: GPL3 | Module: lab.nexedi.com/kirr/go123

Overview

Package xbytes provides additional utilities for working with byte slices.

Index

func ContainsByte

func ContainsByte(s []byte, c byte) bool

ContainsByte is like bytes.ContainsRune but a bit faster.

func Grow

func Grow(b []byte, n int) []byte

Grow increases length of byte slice by n elements.

If there is not enough capacity the slice is reallocated and copied. The memory for grown elements is not initialized.

func MakeRoom

func MakeRoom(b []byte, n int) []byte

MakeRoom makes sure cap(b) - len(b) >= n.

If there is not enough capacity the slice is reallocated and copied. Length of the slice remains unchanged.

func Realloc

func Realloc(b []byte, n int) []byte

Realloc resizes byte slice to be of length n not preserving content.

If slice length is increased and there is not enough capacity, the slice is reallocated but not copied. The memory for all elements becomes uninitialized.

NOTE semantic is different from C realloc(3) where content is preserved. NOTE use Resize when you need to preserve slice content.

func Realloc64

func Realloc64(b []byte, n int64) []byte

Realloc64 is the same as Realloc but for size typed as int64.

func Resize

func Resize(b []byte, n int) []byte

Resize resizes byte slice to be of length n.

If slice length is increased and there is not enough capacity, the slice is reallocated and copied. The memory for grown elements, if any, is not initialized.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier