You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "zeroshade (via GitHub)" <gi...@apache.org> on 2023/03/06 16:03:46 UTC

[GitHub] [arrow] zeroshade commented on a diff in pull request #34450: GH-33999: [Go] Removed cast from byte[] to string and copied entire string when `Value()` is called

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(a.values[a.offsets[i]:a.offsets[i+1]])`



-- 
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: github-unsubscribe@arrow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org