File tree 1 file changed +6
-12
lines changed
1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change @@ -132,23 +132,17 @@ impl<'a> ToCss for Token<'a> {
132
132
}
133
133
}
134
134
135
- fn to_hex_byte ( value : u8 ) -> u8 {
136
- match value {
137
- 0 ...9 => value + b'0' ,
138
- _ => value - 10 + b'a' ,
139
- }
140
- }
141
-
142
135
fn hex_escape < W > ( ascii_byte : u8 , dest : & mut W ) -> fmt:: Result where W : fmt:: Write {
143
- let high = ascii_byte >> 4 ;
136
+ static HEX_DIGITS : & ' static [ u8 ; 16 ] = b"0123456789abcdef" ;
144
137
let b3;
145
138
let b4;
146
- let bytes = if high > 0 {
147
- let low = ascii_byte & 0x0F ;
148
- b4 = [ b'\\' , to_hex_byte ( high) , to_hex_byte ( low) , b' ' ] ;
139
+ let bytes = if ascii_byte > 0x0F {
140
+ let high = ( ascii_byte >> 4 ) as usize ;
141
+ let low = ( ascii_byte & 0x0F ) as usize ;
142
+ b4 = [ b'\\' , HEX_DIGITS [ high] , HEX_DIGITS [ low] , b' ' ] ;
149
143
& b4[ ..]
150
144
} else {
151
- b3 = [ b'\\' , to_hex_byte ( ascii_byte) , b' ' ] ;
145
+ b3 = [ b'\\' , HEX_DIGITS [ ascii_byte as usize ] , b' ' ] ;
152
146
& b3[ ..]
153
147
} ;
154
148
dest. write_str ( unsafe { str:: from_utf8_unchecked ( & bytes) } )
You can’t perform that action at this time.
0 commit comments