File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33## [ Unreleased]
44
5+ ### Performance
6+
7+ - Pre-allocate more memory for output HTML to avoid resizing.
8+
59## [ 0.8.0] - 2022-01-09
610
711### Added
Original file line number Diff line number Diff line change @@ -208,10 +208,8 @@ impl<'a> CSSInliner<'a> {
208208 /// - Internal CSS selector parsing error;
209209 #[ inline]
210210 pub fn inline ( & self , html : & str ) -> Result < String > {
211- // Allocating the same amount of memory as the input HTML helps to avoid
212- // some allocations, but most probably the output size will be different than
213- // the original HTML
214- let mut out = Vec :: with_capacity ( html. len ( ) ) ;
211+ // Allocating more memory than the input HTML, as the inlined version is usually bigger
212+ let mut out = Vec :: with_capacity ( html. len ( ) * 2 ) ;
215213 self . inline_to ( html, & mut out) ?;
216214 Ok ( String :: from_utf8_lossy ( & out) . to_string ( ) )
217215 }
You can’t perform that action at this time.
0 commit comments