summaryrefslogtreecommitdiff
path: root/vendor/github.com/klauspost/compress/zstd/bytereader.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-06-17 20:16:44 +0200
committerGitHub <noreply@github.com>2020-06-17 20:16:44 +0200
commit6645e0d6f376b0dbd2bf82b3c708ceb20a6ad920 (patch)
treeb0e7ad7e27d8608f061226497fbdced2102ce054 /vendor/github.com/klauspost/compress/zstd/bytereader.go
parentf293606480669acea375c53de1e2c81044313c05 (diff)
parentac4f4b14829b66f6aa24b75128bd68e3a5fb53b9 (diff)
downloadpodman-6645e0d6f376b0dbd2bf82b3c708ceb20a6ad920.tar.gz
podman-6645e0d6f376b0dbd2bf82b3c708ceb20a6ad920.tar.bz2
podman-6645e0d6f376b0dbd2bf82b3c708ceb20a6ad920.zip
Merge pull request #6648 from vrothberg/vendor-image
vendor github.com/containers/image/v5@v5.5.1
Diffstat (limited to 'vendor/github.com/klauspost/compress/zstd/bytereader.go')
-rw-r--r--vendor/github.com/klauspost/compress/zstd/bytereader.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/vendor/github.com/klauspost/compress/zstd/bytereader.go b/vendor/github.com/klauspost/compress/zstd/bytereader.go
index f708df1c4..2c4fca17f 100644
--- a/vendor/github.com/klauspost/compress/zstd/bytereader.go
+++ b/vendor/github.com/klauspost/compress/zstd/bytereader.go
@@ -4,8 +4,6 @@
package zstd
-import "encoding/binary"
-
// byteReader provides a byte reader that reads
// little endian values from a byte stream.
// The input stream is manually advanced.
@@ -33,7 +31,8 @@ func (b *byteReader) overread() bool {
// Int32 returns a little endian int32 starting at current offset.
func (b byteReader) Int32() int32 {
- b2 := b.b[b.off : b.off+4 : b.off+4]
+ b2 := b.b[b.off:]
+ b2 = b2[:4]
v3 := int32(b2[3])
v2 := int32(b2[2])
v1 := int32(b2[1])
@@ -57,7 +56,25 @@ func (b byteReader) Uint32() uint32 {
}
return v
}
- return binary.LittleEndian.Uint32(b.b[b.off : b.off+4])
+ b2 := b.b[b.off:]
+ b2 = b2[:4]
+ v3 := uint32(b2[3])
+ v2 := uint32(b2[2])
+ v1 := uint32(b2[1])
+ v0 := uint32(b2[0])
+ return v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)
+}
+
+// Uint32NC returns a little endian uint32 starting at current offset.
+// The caller must be sure if there are at least 4 bytes left.
+func (b byteReader) Uint32NC() uint32 {
+ b2 := b.b[b.off:]
+ b2 = b2[:4]
+ v3 := uint32(b2[3])
+ v2 := uint32(b2[2])
+ v1 := uint32(b2[1])
+ v0 := uint32(b2[0])
+ return v0 | (v1 << 8) | (v2 << 16) | (v3 << 24)
}
// unread returns the unread portion of the input.