MCPcopy Create free account
hub / github.com/TheAlgorithms/Go / RLEdecodebytes

Function RLEdecodebytes

compression/rlecoding.go:67–76  ·  view source on GitHub ↗

RLEdecodebytes takes a run-length encoded byte slice and returns the original byte slice

(data []byte)

Source from the content-addressed store, hash-verified

65
66// RLEdecodebytes takes a run-length encoded byte slice and returns the original byte slice
67func RLEdecodebytes(data []byte) []byte {
68 var result []byte
69
70 for i := 0; i < len(data); i += 2 {
71 count := int(data[i])
72 result = append(result, bytes.Repeat([]byte{data[i+1]}, count)...)
73 }
74
75 return result
76}

Callers 2

BenchmarkRLEDecodeBytesFunction · 0.92

Calls

no outgoing calls

Tested by 2

BenchmarkRLEDecodeBytesFunction · 0.74