File tree 2 files changed +6
-9
lines changed
2 files changed +6
-9
lines changed Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ fn ascii_escapes(b: &mut Bencher) {
44
44
assert_fmt (
45
45
s,
46
46
r#""some\tmore\tascii\ttext\nthis time with some \"escapes\", also 64 byte""# ,
47
- 21 ,
47
+ 15 ,
48
48
) ;
49
49
b. iter ( || {
50
50
black_box ( format ! ( "{:?}" , black_box( s) ) ) ;
@@ -72,7 +72,7 @@ fn mostly_unicode(b: &mut Bencher) {
72
72
#[ bench]
73
73
fn mixed ( b : & mut Bencher ) {
74
74
let s = "\" ❤️\" \n \" hűha ez betű\" \n \" кириллических букв\" ." ;
75
- assert_fmt ( s, r#""\"❤\u{fe0f}\"\n\"hűha ez betű\"\n\"кириллических букв\".""# , 36 ) ;
75
+ assert_fmt ( s, r#""\"❤\u{fe0f}\"\n\"hűha ez betű\"\n\"кириллических букв\".""# , 21 ) ;
76
76
b. iter ( || {
77
77
black_box ( format ! ( "{:?}" , black_box( s) ) ) ;
78
78
} ) ;
Original file line number Diff line number Diff line change @@ -2409,9 +2409,7 @@ impl Debug for str {
2409
2409
// If char needs escaping, flush backlog so far and write, else skip
2410
2410
if esc. len ( ) != 1 {
2411
2411
f. write_str ( & self [ from..i] ) ?;
2412
- for c in esc {
2413
- f. write_char ( c) ?;
2414
- }
2412
+ Display :: fmt ( & esc, f) ?;
2415
2413
from = i + c. len_utf8 ( ) ;
2416
2414
}
2417
2415
}
@@ -2431,13 +2429,12 @@ impl Display for str {
2431
2429
impl Debug for char {
2432
2430
fn fmt ( & self , f : & mut Formatter < ' _ > ) -> Result {
2433
2431
f. write_char ( '\'' ) ?;
2434
- for c in self . escape_debug_ext ( EscapeDebugExtArgs {
2432
+ let esc = self . escape_debug_ext ( EscapeDebugExtArgs {
2435
2433
escape_grapheme_extended : true ,
2436
2434
escape_single_quote : true ,
2437
2435
escape_double_quote : false ,
2438
- } ) {
2439
- f. write_char ( c) ?
2440
- }
2436
+ } ) ;
2437
+ Display :: fmt ( & esc, f) ?;
2441
2438
f. write_char ( '\'' )
2442
2439
}
2443
2440
}
You can’t perform that action at this time.
0 commit comments