class

Rayo::Buf

Inherits Reference < Object

A growable byte buffer on raw malloc, allocated once and reused: with the GC compiled out (-Dgc_none) every per-request byte lives in buffers like this one.

Constants

DIGITS2 = "00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"
HEX = "0123456789abcdef"
L01 = 72340172838076673_u64
L80 = 9259542123273814144_u64

Constructors

new(cap : Int32)
Source

Instance methods

<<(b : UInt8) : self
Source
<<(s : String) : self

String literals are static data, so this is a plain memcpy.

Source
<<(v : Int64) : self
Source
<<(v : Int32) : self
Source
clear
Source
json_escape(p : Pointer(UInt8), n : Int32) : self

Escapes a UTF-8 string into a JSON string body (no quotes). 8 bytes at a time (SWAR): a word is copied unchanged unless it holds a control byte, '"' or ''.

Source
len=(len : Int32)
Source
reserve(n : Int32) : Pointer(UInt8)
Source
shrink(above : Int32, to : Int32) : Nil

Returns memory kept from one large message to the allocator. Only an empty buffer shrinks, so no pointer into it can be live.

Source
tail
Source
write(p : Pointer(UInt8), n : Int32) : self
Source