gohacks

package
v0.0.0-...-4bf4b70 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2021 License: Apache-2.0, MIT Imports: 2 Imported by: 0

Documentation

Overview

Package gohacks contains utilities for subverting the Go compiler.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImmutableBytesFromString

func ImmutableBytesFromString(s string) []byte

ImmutableBytesFromString is equivalent to []byte(s), except that it uses the same memory backing s instead of making a heap-allocated copy. This is only valid if the returned slice is never mutated.

func Noescape

func Noescape(p unsafe.Pointer) unsafe.Pointer

Noescape hides a pointer from escape analysis. Noescape is the identity function but escape analysis doesn't think the output depends on the input. Noescape is inlined and currently compiles down to zero instructions. USE CAREFULLY!

(Noescape is copy/pasted from Go's runtime/stubs.go:noescape().)

func StringFromImmutableBytes

func StringFromImmutableBytes(bs []byte) string

StringFromImmutableBytes is equivalent to string(bs), except that it uses the same memory backing bs instead of making a heap-allocated copy. This is only valid if bs is never mutated after StringFromImmutableBytes returns.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL