summaryrefslogtreecommitdiffstats
path: root/vendor/go.mongodb.org/mongo-driver/bson
diff options
context:
space:
mode:
authortechknowlogick <techknowlogick@gitea.io>2021-02-28 18:08:33 -0500
committerGitHub <noreply@github.com>2021-02-28 18:08:33 -0500
commit47f6a4ec3f058f69b65fb6501d6ac98994b8f8da (patch)
tree4d1421a4c836de9de4014117419c151035c17eec /vendor/go.mongodb.org/mongo-driver/bson
parent030646eea41e17e58e11e73b19339630b6d6148e (diff)
downloadgitea-47f6a4ec3f058f69b65fb6501d6ac98994b8f8da.tar.gz
gitea-47f6a4ec3f058f69b65fb6501d6ac98994b8f8da.zip
go1.16 (#14783)
Diffstat (limited to 'vendor/go.mongodb.org/mongo-driver/bson')
-rw-r--r--vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go58
1 files changed, 13 insertions, 45 deletions
diff --git a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
index dd560c96f6..b83012b21c 100644
--- a/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
+++ b/vendor/go.mongodb.org/mongo-driver/bson/bsonrw/extjson_reader.go
@@ -159,29 +159,18 @@ func (ejvr *extJSONValueReader) pop() {
}
}
-func (ejvr *extJSONValueReader) skipDocument() error {
- // read entire document until ErrEOD (using readKey and readValue)
- _, typ, err := ejvr.p.readKey()
- for err == nil {
- _, err = ejvr.p.readValue(typ)
- if err != nil {
- break
+func (ejvr *extJSONValueReader) skipObject() {
+ // read entire object until depth returns to 0 (last ending } or ] seen)
+ depth := 1
+ for depth > 0 {
+ ejvr.p.advanceState()
+ switch ejvr.p.s {
+ case jpsSawBeginObject, jpsSawBeginArray:
+ depth++
+ case jpsSawEndObject, jpsSawEndArray:
+ depth--
}
-
- _, typ, err = ejvr.p.readKey()
}
-
- return err
-}
-
-func (ejvr *extJSONValueReader) skipArray() error {
- // read entire array until ErrEOA (using peekType)
- _, err := ejvr.p.peekType()
- for err == nil {
- _, err = ejvr.p.peekType()
- }
-
- return err
}
func (ejvr *extJSONValueReader) invalidTransitionErr(destination mode, name string, modes []mode) error {
@@ -234,30 +223,9 @@ func (ejvr *extJSONValueReader) Skip() error {
t := ejvr.stack[ejvr.frame].vType
switch t {
- case bsontype.Array:
- // read entire array until ErrEOA
- err := ejvr.skipArray()
- if err != ErrEOA {
- return err
- }
- case bsontype.EmbeddedDocument:
- // read entire doc until ErrEOD
- err := ejvr.skipDocument()
- if err != ErrEOD {
- return err
- }
- case bsontype.CodeWithScope:
- // read the code portion and set up parser in document mode
- _, err := ejvr.p.readValue(t)
- if err != nil {
- return err
- }
-
- // read until ErrEOD
- err = ejvr.skipDocument()
- if err != ErrEOD {
- return err
- }
+ case bsontype.Array, bsontype.EmbeddedDocument, bsontype.CodeWithScope:
+ // read entire array, doc or CodeWithScope
+ ejvr.skipObject()
default:
_, err := ejvr.p.readValue(t)
if err != nil {