zeroshade commented on code in PR #35723:
URL: https://github.com/apache/arrow/pull/35723#discussion_r1210696225


##########
go/arrow/array/string.go:
##########
@@ -79,16 +79,12 @@ func (a *String) ValueOffsets() []int32 {
        return a.offsets[beg:end]
 }
 
-func (a *String) ValueBytes() (ret []byte) {
+func (a *String) ValueBytes() []byte {
        beg := a.array.data.offset
        end := beg + a.array.data.length
        data := a.values[a.offsets[beg]:a.offsets[end]]
 
-       s := (*reflect.SliceHeader)(unsafe.Pointer(&ret))
-       s.Data = (*reflect.StringHeader)(unsafe.Pointer(&data)).Data
-       s.Len = len(data)
-       s.Cap = len(data)
-       return
+       return []byte(data)

Review Comment:
   Strings in Go are immutable, so unless the compiler can confirm that 
`[]byte(str)` is only used as a temporary it will do a copy of the bytes to 
construct the byte slice from the string. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to