summaryrefslogtreecommitdiff
path: root/vendor/github.com/uptrace/bun/extra/bunotel/unsafe.go
blob: 67b687cbe38aa54b8e8c9b0ea3e96ad2c2fe4928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//go:build !appengine
// +build !appengine

package bunotel

import "unsafe"

func bytesToString(b []byte) string {
	if len(b) == 0 {
		return ""
	}
	return unsafe.String(&b[0], len(b))
}

func stringToBytes(s string) []byte {
	if s == "" {
		return []byte{}
	}
	return unsafe.Slice(unsafe.StringData(s), len(s))
}