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.
| 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. |
| 222 | pub 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 | |
| 236 | impl Default for DocumentBuffers { |
| 237 | fn default() -> Self { |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…