bytes

package
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 11, 2023 License: BSD-3-Clause Imports: 5 Imported by: 14

README

goos: linux
goarch: amd64
BenchmarkIsZeroFilled/size_0/default-8 	1000000000	         3.03 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_0/simple-8  	1000000000	         2.93 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_1/default-8 	1000000000	         4.74 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_1/simple-8  	1000000000	         3.31 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_256/default-8         	212255557	        28.4 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_256/simple-8          	71001369	        86.8 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_65536/default-8       	 1466428	      3961 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_65536/simple-8        	  308932	     19780 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_1048576/default-8     	  106068	     65791 ns/op	       0 B/op	       0 allocs/op
BenchmarkIsZeroFilled/size_1048576/simple-8      	   17924	    335547 ns/op	       0 B/op	       0 allocs/op
PASS
ok  	_/home/xaionaro/go/src/github.com/9elements/converged-security-suite/v2/cmd/pcr0tool/pkg/bytes	63.711s

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsZeroFilled

func IsZeroFilled(b []byte) bool

IsZeroFilled returns true if b consists of zeros only.

Types

type Range

type Range struct {
	Offset uint64
	Length uint64
}

Range defines is a generic bytes range headers.

func (Range) End

func (r Range) End() uint64

End returns the first offset after the range.

func (Range) Exclude

func (r Range) Exclude(_toExcludes ...Range) Ranges

Exclude returns the parts of the range, which excludes the selected ones.

func (Range) Intersect

func (r Range) Intersect(cmp Range) bool

Intersect returns True if ranges "r" and "cmp" has at least one byte with the same offset.

func (Range) String

func (r Range) String() string

type Ranges

type Ranges []Range

Ranges is a helper to manipulate multiple `Range`-s at once

func MergeRanges

func MergeRanges(in Ranges, mergeDistance uint64) Ranges

MergeRanges just merges ranges which has distance less or equal to mergeDistance.

Warning: should be called only on sorted ranges!

func (Ranges) Compile

func (s Ranges) Compile(b []byte) []byte

Compile returns the bytes from `b` which are referenced by `Range`-s `s`.

func (Ranges) IsIn

func (s Ranges) IsIn(index uint64) bool

IsIn returns if the index is covered by this ranges

func (Ranges) Sort

func (s Ranges) Sort()

Sort sorts the slice by field Offset

func (*Ranges) SortAndMerge

func (s *Ranges) SortAndMerge()

SortAndMerge sorts the slice (by field Offset) and the merges ranges which could be merged.

func (Ranges) String

func (s Ranges) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL