hack

package
v0.0.0-...-440800f Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 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 Bytes

func Bytes(s string) []byte

Bytes bring a no copy convert from string to byte slice consider the risk

func BytesFromPtr

func BytesFromPtr(ptr uintptr, len int) []byte

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