@@ -399,6 +399,11 @@ fn write_declaration<Wr: Write>(
399
399
) -> Result < ( ) , InlineError > {
400
400
writer. write_all ( name. as_bytes ( ) ) ?;
401
401
writer. write_all ( STYLE_SEPARATOR ) ?;
402
+ write_declaration_value ( writer, value)
403
+ }
404
+
405
+ #[ inline]
406
+ fn write_declaration_value < Wr : Write > ( writer : & mut Wr , value : & str ) -> Result < ( ) , InlineError > {
402
407
let value = value. trim ( ) ;
403
408
if value. as_bytes ( ) . contains ( & b'"' ) {
404
409
// Roughly based on `str::replace`
@@ -429,9 +434,7 @@ macro_rules! push_or_update {
429
434
( $style_buffer: expr, $length: expr, $name: expr, $value: expr) => { {
430
435
if let Some ( style) = $style_buffer. get_mut( $length) {
431
436
style. clear( ) ;
432
- style. extend_from_slice( $name. as_bytes( ) ) ;
433
- style. extend_from_slice( STYLE_SEPARATOR ) ;
434
- style. extend_from_slice( $value. trim( ) . as_bytes( ) ) ;
437
+ write_declaration( style, & $name, $value) ?;
435
438
} else {
436
439
let value = $value. trim( ) ;
437
440
let mut style = Vec :: with_capacity(
@@ -440,9 +443,7 @@ macro_rules! push_or_update {
440
443
. saturating_add( STYLE_SEPARATOR . len( ) )
441
444
. saturating_add( value. len( ) ) ,
442
445
) ;
443
- style. extend_from_slice( $name. as_bytes( ) ) ;
444
- style. extend_from_slice( STYLE_SEPARATOR ) ;
445
- style. extend_from_slice( value. as_bytes( ) ) ;
446
+ write_declaration( & mut style, & $name, $value) ?;
446
447
$style_buffer. push( style) ;
447
448
} ;
448
449
$length = $length. saturating_add( 1 ) ;
@@ -507,7 +508,7 @@ fn merge_styles<Wr: Write>(
507
508
( Some ( value) , Some ( buffer) ) => {
508
509
// We keep the rule name and the colon-space suffix - '<rule>: `
509
510
buffer. truncate ( property. len ( ) . saturating_add ( STYLE_SEPARATOR . len ( ) ) ) ;
510
- buffer . extend_from_slice ( value. trim ( ) . as_bytes ( ) ) ;
511
+ write_declaration_value ( buffer , value) ? ;
511
512
}
512
513
// There's no existing rule with the same name, but the new rule is `!important`
513
514
// In this case, we add the new rule with the `!important` suffix removed
0 commit comments