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

package internal

import "unsafe"

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

// Bytes converts string to byte slice.
func Bytes(s string) []byte {
	if s == "" {
		return []byte{}
	}
	return unsafe.Slice(unsafe.StringData(s), len(s))
}