MCPcopy Create free account
hub / github.com/untitaker/hyperlink / DocumentBuffers

Class DocumentBuffers

src/html/mod.rs:222–234  ·  view source on GitHub ↗

This struct is initialized once per "batch of documents" that will be processed on a single worker thread (as determined by rayon). It pays off to do as much heap allocation as possible here once instead of in Document::links.

Source from the content-addressed store, hash-verified

220/// worker thread (as determined by rayon). It pays off to do as much heap allocation as possible
221/// here once instead of in Document::links.
222pub struct DocumentBuffers {
223 arena: bumpalo::Bump,
224 html_read_buffer: Box<[u8; BUF_SIZE]>,
225 parser_buffers: parser::ParserBuffers,
226 /// Scratch space for building hrefs in. The final string is copied into the arena with
227 /// alloc_str, so the arena never sees any grow-and-copy garbage.
228 href_buf: String,
229 /// Scratch space for the parser's paragraph link buffer. Outside of links_from_read this is
230 /// always empty, only the allocation is reused across documents (the 'static lifetime is
231 /// laundered through recycle()). Buffered links never carry a paragraph -- it is attached
232 /// when the buffer is flushed -- hence VoidParagraph.
233 link_buf: Vec<Link<'static, VoidParagraph>>,
234}
235
236impl Default for DocumentBuffers {
237 fn default() -> Self {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…