File: zerocopy.go

package info (click to toggle)
golang-github-dhowett-go-plist 0.0~git20181124.0.591f970-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 376 kB
  • sloc: makefile: 2
file content (20 lines) | stat: -rw-r--r-- 304 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
// +build !appengine

package plist

import (
	"reflect"
	"unsafe"
)

func zeroCopy8BitString(buf []byte, off int, len int) string {
	if len == 0 {
		return ""
	}

	var s string
	hdr := (*reflect.StringHeader)(unsafe.Pointer(&s))
	hdr.Data = uintptr(unsafe.Pointer(&buf[off]))
	hdr.Len = len
	return s
}