@@ -35,10 +35,6 @@ import (
3535// Magic string identifying an Apache Arrow file.
3636var Magic = []byte ("ARROW1" )
3737
38- func tostr (b []byte ) string {
39- return unsafe .String (& b [0 ], len (b ))
40- }
41-
4238const (
4339 currentMetadataVersion = MetadataV5
4440 minMetadataVersion = MetadataV4
@@ -188,7 +184,8 @@ func fieldFromFB(field *flatbuf.Field, pos dictutils.FieldPos, memo *dictutils.M
188184 o arrow.Field
189185 )
190186
191- o .Name = tostr (field .Name ())
187+ name := field .Name ()
188+ o .Name = unsafe .String (& name [0 ], len (name ))
192189 o .Nullable = field .Nullable ()
193190 o .Metadata , err = metadataFromFB (field )
194191 if err != nil {
@@ -991,8 +988,9 @@ func timeFromFB(data flatbuf.Time) (arrow.DataType, error) {
991988
992989func timestampFromFB (data flatbuf.Timestamp ) (arrow.DataType , error ) {
993990 unit := unitFromFB (data .Unit ())
994- tz := tostr (data .Timezone ())
995- return & arrow.TimestampType {Unit : unit , TimeZone : tz }, nil
991+ tz := data .Timezone ()
992+ tzs := unsafe .String (& tz [0 ], len (tz ))
993+ return & arrow.TimestampType {Unit : unit , TimeZone : tzs }, nil
996994}
997995
998996func dateFromFB (data flatbuf.Date ) (arrow.DataType , error ) {
@@ -1047,8 +1045,8 @@ func metadataFromFB(md customMetadataer) (arrow.Metadata, error) {
10471045 if ! md .CustomMetadata (& kv , i ) {
10481046 return arrow.Metadata {}, fmt .Errorf ("arrow/ipc: could not read key-value %d from flatbuffer" , i )
10491047 }
1050- keys [i ] = tostr (kv .Key ())
1051- vals [i ] = tostr (kv .Value ())
1048+ keys [i ] = string (kv .Key ())
1049+ vals [i ] = string (kv .Value ())
10521050 }
10531051
10541052 return arrow .NewMetadata (keys , vals ), nil
0 commit comments