b2s_new.go 285 B

1234567891011
  1. //go:build go1.20
  2. package fasthttp
  3. import "unsafe"
  4. // b2s converts byte slice to a string without memory allocation.
  5. // See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
  6. func b2s(b []byte) string {
  7. return unsafe.String(unsafe.SliceData(b), len(b))
  8. }