Skip to main content
Hot paths skip the heap. These types give you fixed-capacity containers and stack path builders.

BoundedArray

Drop-in for removed std.BoundedArray in Zig 0.15+. Same idea: fixed capacity, dynamic length, nothing on the heap.
const utils = @import("otter_utils");

var arr = utils.BoundedArray(u8, 256){};
try arr.append(42);
try arr.appendSlice("hello");

const slice = arr.constSlice();
Use for hit region lists, workspace IDs, damage rects, and any bounded collection in daemons.

FilePath

Stack buffer sized to fs.max_path_bytes. Build paths from segments without allocating.
const FilePath = @import("otter_utils").FilePath;

const path = try FilePath.from("/home/user/docs");
const path2 = try FilePath.fromMany(&.{ "home", "user", "docs" });

var builder = try FilePath.from("/home");
try builder.appendSegment("user");
const s = builder.slice(); // [:0]const u8

_ = builder.pop(); // returns removed segment

FixedString

Small inline string buffer for titles, labels, and protocol names that must stay on the stack. See fixed_string.zig for capacity and append APIs.

When to use what

TypeCapacityBest for
BoundedArray(T, N)Comptime NHomogeneous lists (IDs, rects, events)
FilePathmax_path_bytesConfig paths, icon paths, socket paths
FixedString(N)Comptime NShort names and cached strings