@@ -16,7 +16,6 @@ use std::iter;
16
16
use std:: path:: Path ;
17
17
18
18
use derive_setters:: Setters ;
19
- use either:: Either ;
20
19
use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap , FxIndexSet } ;
21
20
use rustc_data_structures:: sync:: { DynSend , IntoDynSyncSend , Lrc } ;
22
21
use rustc_error_messages:: { FluentArgs , SpanLabel } ;
@@ -2609,16 +2608,21 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
2609
2608
( '\u{2069}' , "�" ) ,
2610
2609
] ;
2611
2610
2612
- fn normalize_whitespace ( str : & str ) -> String {
2611
+ fn normalize_whitespace ( s : & str ) -> String {
2613
2612
// Scan the input string for a character in the ordered table above. If it's present, replace
2614
2613
// it with it's alternative string (it can be more than 1 char!). Otherwise, retain the input
2615
2614
// char. At the end, allocate all chars into a string in one operation.
2616
- str. chars ( )
2617
- . flat_map ( |c| match OUTPUT_REPLACEMENTS . binary_search_by_key ( & c, |( k, _) | * k) {
2618
- Ok ( i) => Either :: Left ( OUTPUT_REPLACEMENTS [ i] . 1 . chars ( ) ) ,
2619
- _ => Either :: Right ( [ c] . into_iter ( ) ) ,
2620
- } )
2621
- . collect ( )
2615
+ s. chars ( ) . fold ( String :: with_capacity ( s. len ( ) ) , |mut s, c| {
2616
+ match OUTPUT_REPLACEMENTS . binary_search_by_key ( & c, |( k, _) | * k) {
2617
+ Ok ( i) => {
2618
+ for c in OUTPUT_REPLACEMENTS [ i] . 1 . chars ( ) {
2619
+ s. push ( c) ;
2620
+ }
2621
+ }
2622
+ _ => s. push ( c) ,
2623
+ }
2624
+ s
2625
+ } )
2622
2626
}
2623
2627
2624
2628
fn draw_col_separator ( buffer : & mut StyledBuffer , line : usize , col : usize ) {
0 commit comments