hack

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package hack gives you some efficient functionality at the cost of breaking some Go rules.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String(b []byte) (s string)

String force casts a []byte to a string. USE AT YOUR OWN RISK

func StringPointer

func StringPointer(s string) unsafe.Pointer

StringPointer returns &s[0], which is not allowed in go

Types

type StringArena

type StringArena struct {
	// contains filtered or unexported fields
}

StringArena lets you consolidate allocations for a group of strings that have similar life length

func NewStringArena

func NewStringArena(size int) *StringArena

NewStringArena creates an arena of the specified size.

func (*StringArena) NewString

func (sa *StringArena) NewString(b []byte) string

NewString copies a byte slice into the arena and returns it as a string. If the arena is full, it returns a traditional go string.

func (*StringArena) SpaceLeft

func (sa *StringArena) SpaceLeft() int

SpaceLeft returns the amount of space left in the arena.

Jump to

Keyboard shortcuts

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