aboutsummaryrefslogtreecommitdiff
path: root/b2s_old.go
blob: f6e9466a9a20ef730957b4e885e469ef10f538db (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
//go:build !go1.20

package fasthttp

import "unsafe"

// b2s converts byte slice to a string without memory allocation.
// See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
//
// Note it may break if string and/or slice header will change
// in the future go versions.
func b2s(b []byte) string {
	return *(*string)(unsafe.Pointer(&b))
}