mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-25 08:08:39 +00:00
Fix heap allocation when reading a string.
This commit is contained in:
@@ -43,3 +43,8 @@ var (
|
||||
// SizeVOffsetT is the byte size of an VOffsetT.
|
||||
SizeVOffsetT = int(unsafe.Sizeof(VOffsetT(0)))
|
||||
)
|
||||
|
||||
// byteSliceToString converts a []byte to string without a heap allocation.
|
||||
func byteSliceToString(b []byte) string {
|
||||
return *(*string)(unsafe.Pointer(&b))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user