low

package
v0.14.1 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunID string

RunID is a random string generated at start.

View Source
var Spaces = []byte("                                                                                                                                                ")

Spaces is for padding strings.

Used as buf = append(buf, Spaces[:padWidth]...)

Functions

func AppendPrint added in v0.11.0

func AppendPrint(b []byte, a ...interface{}) []byte

AppendPrint is similar to fmt.Sprint but faster. See doc for AppendPrintf for more details.

func AppendPrintf

func AppendPrintf(b []byte, format string, a ...interface{}) []byte

AppendPrintf is similar to fmt.Fprintf but a little bit hacked.

There is no sync.Pool.Get and Put. There is no copying buffer to io.Writer or conversion to string. There is no io.Writer interface dereference. All that gives advantage about 30-50 ns per call. Yes, I know :).

func AppendPrintln

func AppendPrintln(b []byte, a ...interface{}) []byte

AppendPrintln is similar to fmt.Sprintln but faster. See doc for AppendPrintf for more details.

func AppendQuote

func AppendQuote(b, s []byte) []byte

func AppendQuoteString added in v0.13.0

func AppendQuoteString(b []byte, s string) []byte

func AppendSafe

func AppendSafe(b, s []byte) []byte

AppendSafe appends string to buffer with JSON compatible esaping. It does NOT add quotes.

func AppendSafeString added in v0.13.0

func AppendSafeString(b []byte, s string) []byte

func BytesHash

func BytesHash(s []byte, h uintptr) uintptr

BytesHash is fast builtin hash function.

func Fastrand

func Fastrand() uint32

Fastrand is runtime.fastrand.

func Getbuf

func Getbuf() (_ Buf, wr *Bwr)

Getbuf gets bytes buffer from a pool to reduce gc pressure. buffer is at least 100 bytes long. Buffer must be returned after used. Usage:

b, wr := tlog.Getbuf()
defer wr.Ret(&b)

b = append(b[:0], ...)

func InterfaceData added in v0.11.0

func InterfaceData(v interface{}) unsafe.Pointer

func IsNil added in v0.11.0

func IsNil(v interface{}) bool

func MemHash

func MemHash(p unsafe.Pointer, h, s uintptr) uintptr

MemHash is fast builtin hash function.

func MemHash32

func MemHash32(p unsafe.Pointer, h uintptr) uintptr

MemHash32 is fast builtin hash function.

func MemHash64

func MemHash64(p unsafe.Pointer, h uintptr) uintptr

MemHash64 is fast builtin hash function.

func Monotonic

func Monotonic() (t int64)

Monotonic is runtime function. It returns monotonic nanoseconds.

func MonotonicDuration

func MonotonicDuration() (t time.Duration)

MonotonicDuration is runtime function. It returns monotonic time.

func Since

func Since(monotonic int64) time.Duration

func SplitTime

func SplitTime(t time.Time) (year, month, day, hour, min, sec int)

SplitTime is faster version of t.Date(); t.Clock().

func StrHash

func StrHash(s string, h uintptr) uintptr

StrHash is fast builtin hash function.

func UnixNano

func UnixNano() (t int64)

func UnsafeBytesToString

func UnsafeBytesToString(b []byte) string

func UnsafeString added in v0.11.0

func UnsafeString(ptr unsafe.Pointer, l int) string

Types

type Buf

type Buf []byte

func (*Buf) NewLine

func (w *Buf) NewLine()

func (*Buf) Reset added in v0.11.0

func (w *Buf) Reset()

func (*Buf) Write

func (w *Buf) Write(p []byte) (int, error)

type Bwr

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

func (*Bwr) Ret

func (wr *Bwr) Ret(b *Buf)

Jump to

Keyboard shortcuts

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