zeroshade commented on code in PR #34450:
URL: https://github.com/apache/arrow/pull/34450#discussion_r1126671392
##########
go/arrow/array/string.go:
##########
@@ -50,8 +50,11 @@ func (a *String) Reset(data arrow.ArrayData) {
// Value returns the slice at index i. This value should not be mutated.
func (a *String) Value(i int) string {
+ sb := strings.Builder{}
+
i = i + a.array.data.offset
- return a.values[a.offsets[i]:a.offsets[i+1]]
+ sb.WriteString(a.values[a.offsets[i]:a.offsets[i+1]])
+ return sb.String()
Review Comment:
There's no need to use the string builder here, you can just do
`string([]byte(a.values[a.offsets[i]:a.offsets[i+1]])[:])` or something like:
```go
val := a.values[a.offsets[i]:a.offsets[i+1]]
out := make([]byte, len(val))
copy(out, val)
return *(*string)(unsafe.Pointer(&out))
```
--
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]