Skip to main content

BinderScratch

Struct BinderScratch 

Source
pub struct BinderScratch { /* private fields */ }
Expand description

The vectors a binder works in, kept by the connection rather than made for every statement.

The parse arena’s counterpart, for the stage after the parse (task-2026). Compiled::scratch_ast exists because every vector in an Ast is empty at construction and grows on its first push, so a parse that is thrown away a microsecond later pays the allocator for capacity it already had last time. The binder has exactly that shape and was not getting that treatment: binding SELECT 1 took the scope stack’s buffer and the result-alias buffer - 96 and 320 bytes - out of the allocator on every compile, and prepare.trivial is a workload the gate compiles on every iteration.

What is here is the binder’s own working state. What the binder returns is not: a BoundStatement’s vectors leave with it and belong to whoever asked for the bind, so recycling them would mean handing back memory something else is still reading.

Like the arena, it is cleared on the way in rather than on the way out, and it keeps whatever capacity the largest statement so far needed - a connection that once bound a statement with ten thousand FROM terms holds that much sources until it closes. That is the trade crate::ast::Ast already makes, made once more here rather than differently.

Implementations§

Source§

impl BinderScratch

Source

pub fn new() -> BinderScratch

Returns a scratch with nothing in it and nothing allocated.

Trait Implementations§

Source§

impl Default for BinderScratch

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.