Skip to documentation
SLOP

tiny.reducer.Capacity

Reference tiny.reducer Capacity

Defined in bytes.capacity.

Workspace layout derived from the caller's limits, sized so that a run in steady state needs no further allocation.

API (5)

Actions

Public operations.

Fields and members

Public fields and members.

No direct callersNo direct callsbytes.capacityCapacity
Static calls · unresolved targets: unknown · external targets: unknown.

Source

Source: lib/reducer/src/bytes/capacity.zig:56

zig
/// Workspace layout derived from the caller's limits, sized so that a run in/// steady state needs no further allocation.pub const Capacity = struct {    /// Caller's limits that this capacity was derived from.    limits: Limits,    /// Byte offset in the backing allocation where the scratch lane starts. It    /// equals `limits.max_input_bytes` exactly.    candidate_offset: usize,    /// Greatest length in bytes any candidate takes, which is $\max(N - 1, 0)$.    candidate_bytes: usize,    /// Total the combined allocation needs, which is    /// $\text{candidate\_offset} + \text{candidate\_bytes}$.    storage_bytes: usize,    /// Works out the memory a workspace needs to reduce inputs up to    /// `limits.max_input_bytes`. It computes $N + \max(N - 1, 0)$, taking the    /// scratch lane's length with saturating subtraction and the total with    /// checked addition. It produces the arithmetic layout alone and calls no    /// allocator.    ///    /// ## Errors    /// It returns `DeriveError.CapacityOverflow` when the combined requirement    /// exceeds `std.math.maxInt(usize)`.    pub fn derive(limits: Limits) DeriveError!Capacity {        const candidate_bytes = limits.max_input_bytes -| 1;        const capacity = Capacity{            .limits = limits,            .candidate_offset = limits.max_input_bytes,            .candidate_bytes = candidate_bytes,            .storage_bytes = std.math.add(                usize,                limits.max_input_bytes,                candidate_bytes,            ) catch return error.CapacityOverflow,        };        std.debug.assert(capacity.candidate_offset == limits.max_input_bytes);        std.debug.assert(capacity.candidate_bytes <= limits.max_input_bytes);        std.debug.assert(capacity.storage_bytes >= limits.max_input_bytes);        std.debug.assert(            capacity.candidate_offset + capacity.candidate_bytes == capacity.storage_bytes,        );        return capacity;    }};

Source: lib/reducer/src/root.zig:317

zig
/// Workspace layout derived from the caller's limits, sized so that a run in/// steady state needs no further allocation.pub const Capacity = bytes.Capacity;
Called byCallsNo direct callstest sourcelib.reducer.src.bytes.capacitytest: byte storage capacity accepts i...test sourcelib.reducer.src.bytes.capacitytest: byte storage capacity matches a...Capacityderive
Static calls · unresolved targets: 0 · external targets: 0.

Also reachable as

bytes.Capacity.

Audit

Definitions2
Public names6
Members4
Version26.7.0
Revisiondaab053ee433