@@ -250,7 +250,7 @@ func (v Value) String() string {
250
250
if ! ok {
251
251
return ""
252
252
}
253
- return docAsArray ( arr , false )
253
+ return arr . String ( )
254
254
case bsontype .Binary :
255
255
subtype , data , ok := v .BinaryOK ()
256
256
if ! ok {
@@ -366,7 +366,7 @@ func (v Value) DebugString() string {
366
366
if ! ok {
367
367
return "<malformed>"
368
368
}
369
- return docAsArray ( arr , true )
369
+ return arr . DebugString ( )
370
370
case bsontype .CodeWithScope :
371
371
code , scope , ok := v .CodeWithScopeOK ()
372
372
if ! ok {
@@ -464,7 +464,7 @@ func (v Value) DocumentOK() (Document, bool) {
464
464
465
465
// Array returns the BSON array the Value represents as an Array. It panics if the
466
466
// value is a BSON type other than array.
467
- func (v Value ) Array () Document {
467
+ func (v Value ) Array () Array {
468
468
if v .Type != bsontype .Array {
469
469
panic (ElementTypeError {"bsoncore.Value.Array" , v .Type })
470
470
}
@@ -477,7 +477,7 @@ func (v Value) Array() Document {
477
477
478
478
// ArrayOK is the same as Array, except it returns a boolean instead
479
479
// of panicking.
480
- func (v Value ) ArrayOK () (Document , bool ) {
480
+ func (v Value ) ArrayOK () (Array , bool ) {
481
481
if v .Type != bsontype .Array {
482
482
return nil , false
483
483
}
@@ -978,38 +978,3 @@ func sortStringAlphebeticAscending(s string) string {
978
978
sort .Sort (ss )
979
979
return string ([]rune (ss ))
980
980
}
981
-
982
- func docAsArray (d Document , debug bool ) string {
983
- if len (d ) < 5 {
984
- return ""
985
- }
986
- var buf bytes.Buffer
987
- buf .WriteByte ('[' )
988
-
989
- length , rem , _ := ReadLength (d ) // We know we have enough bytes to read the length
990
-
991
- length -= 4
992
-
993
- var elem Element
994
- var ok bool
995
- first := true
996
- for length > 1 {
997
- if ! first {
998
- buf .WriteByte (',' )
999
- }
1000
- elem , rem , ok = ReadElement (rem )
1001
- length -= int32 (len (elem ))
1002
- if ! ok {
1003
- return ""
1004
- }
1005
- if debug {
1006
- fmt .Fprintf (& buf , "%s " , elem .Value ().DebugString ())
1007
- } else {
1008
- fmt .Fprintf (& buf , "%s" , elem .Value ())
1009
- }
1010
- first = false
1011
- }
1012
- buf .WriteByte (']' )
1013
-
1014
- return buf .String ()
1015
- }
0 commit comments