summaryrefslogtreecommitdiff
path: root/vendor/github.com/json-iterator/go/iter_skip.go
diff options
context:
space:
mode:
authorSascha Grunert <sgrunert@suse.com>2019-09-05 16:58:06 +0200
committerSascha Grunert <sgrunert@suse.com>2019-09-05 16:58:08 +0200
commitf66a2069f1b26ff9987b008ba4b0c91ac3b682cc (patch)
tree1219ee0e7b87494eaf2c6ace56d4ecada0dc4a39 /vendor/github.com/json-iterator/go/iter_skip.go
parentb962b1e3538312f145aea0cf5546ae31f35f635f (diff)
downloadpodman-f66a2069f1b26ff9987b008ba4b0c91ac3b682cc.tar.gz
podman-f66a2069f1b26ff9987b008ba4b0c91ac3b682cc.tar.bz2
podman-f66a2069f1b26ff9987b008ba4b0c91ac3b682cc.zip
Update buildah to v1.11.0
Vendor in the latest changes for buildah to apply the implemented features here as well. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
Diffstat (limited to 'vendor/github.com/json-iterator/go/iter_skip.go')
-rw-r--r--vendor/github.com/json-iterator/go/iter_skip.go25
1 files changed, 13 insertions, 12 deletions
diff --git a/vendor/github.com/json-iterator/go/iter_skip.go b/vendor/github.com/json-iterator/go/iter_skip.go
index f58beb913..e91eefb15 100644
--- a/vendor/github.com/json-iterator/go/iter_skip.go
+++ b/vendor/github.com/json-iterator/go/iter_skip.go
@@ -37,17 +37,24 @@ func (iter *Iterator) SkipAndReturnBytes() []byte {
return iter.stopCapture()
}
-type captureBuffer struct {
- startedAt int
- captured []byte
+// SkipAndAppendBytes skips next JSON element and appends its content to
+// buffer, returning the result.
+func (iter *Iterator) SkipAndAppendBytes(buf []byte) []byte {
+ iter.startCaptureTo(buf, iter.head)
+ iter.Skip()
+ return iter.stopCapture()
}
-func (iter *Iterator) startCapture(captureStartedAt int) {
+func (iter *Iterator) startCaptureTo(buf []byte, captureStartedAt int) {
if iter.captured != nil {
panic("already in capture mode")
}
iter.captureStartedAt = captureStartedAt
- iter.captured = make([]byte, 0, 32)
+ iter.captured = buf
+}
+
+func (iter *Iterator) startCapture(captureStartedAt int) {
+ iter.startCaptureTo(make([]byte, 0, 32), captureStartedAt)
}
func (iter *Iterator) stopCapture() []byte {
@@ -58,13 +65,7 @@ func (iter *Iterator) stopCapture() []byte {
remaining := iter.buf[iter.captureStartedAt:iter.head]
iter.captureStartedAt = -1
iter.captured = nil
- if len(captured) == 0 {
- copied := make([]byte, len(remaining))
- copy(copied, remaining)
- return copied
- }
- captured = append(captured, remaining...)
- return captured
+ return append(captured, remaining...)
}
// Skip skips a json object and positions to relatively the next json object