Skip to content

Function signatures #14

Description

@pascaldekloe

Encoding as uint32 or uint64 slices is a bit cumbersome. We can use byte slices instead without any loss of performance. Go even optimizes the binary.ByteOrder into native operations.

Decoding needs an error return. The Uncompress functions are panic bombs now. This is bad for performance, e.g, pull request #13.

The output destination should always be the first argument, like a C copy or fprintf, and like a Go io.Copy or fmt.Fprintf. Append functions are better of by naming their behaviour explicitly, e.g., strconv.AppendInt, utf8.AppendRune or time.AppendFormat.

DeltaBin and DeltaVar describe the internal mechanism, which is not useful to the API reader/user.

The trailing-zero optimization is just as useful on signed and unsigned integers.

I propose the following API.

const BlockSize32, BlockSize64 = 128, 256
func AppendEnc64[T uint64|int64](dst []byte, values ...T) []byte
func AppendBlockEnc64[T uint64|int64](dst []byte, values ...T) (out []byte, remain []T)
func AppendDec64[T uint64|int64](dst []T, src []byte) (out []T, err error)
func AppendBlockDec64[T uint64|int64](dst []T, src []byte) (out []T, remain []byte, err error)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions