MCPcopy Create free account
hub / github.com/Stranger6667/css-inline / allocate_output_buffer

Function allocate_output_buffer

css-inline/src/lib.rs:502–514  ·  view source on GitHub ↗
(html: &str)

Source from the content-addressed store, hash-verified

500const DECLARATION_SIZE_COEFFICIENT: f64 = 30.0;
501
502fn allocate_output_buffer(html: &str) -> Vec<u8> {
503 // Allocating more memory than the input HTML, as the inlined version is usually bigger
504 #[allow(
505 clippy::cast_precision_loss,
506 clippy::cast_sign_loss,
507 clippy::cast_possible_truncation
508 )]
509 Vec::with_capacity(
510 (html.len() as f64 * GROWTH_COEFFICIENT)
511 .min(usize::MAX as f64)
512 .round() as usize,
513 )
514}
515
516impl<'a> CSSInliner<'a> {
517 /// Create a new `CSSInliner` instance with given options.

Callers 2

inlineMethod · 0.85
inline_fragmentMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected