@@ -16,7 +16,6 @@ use std::iter;
1616use std:: path:: Path ;
1717
1818use derive_setters:: Setters ;
19- use either:: Either ;
2019use rustc_data_structures:: fx:: { FxHashMap , FxIndexMap , FxIndexSet } ;
2120use rustc_data_structures:: sync:: { DynSend , IntoDynSyncSend , Lrc } ;
2221use rustc_error_messages:: { FluentArgs , SpanLabel } ;
@@ -2609,16 +2608,21 @@ const OUTPUT_REPLACEMENTS: &[(char, &str)] = &[
26092608 ( '\u{2069}' , "�" ) ,
26102609] ;
26112610
2612- fn normalize_whitespace ( str : & str ) -> String {
2611+ fn normalize_whitespace ( s : & str ) -> String {
26132612 // Scan the input string for a character in the ordered table above. If it's present, replace
26142613 // it with it's alternative string (it can be more than 1 char!). Otherwise, retain the input
26152614 // 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+ } )
26222626}
26232627
26242628fn draw_col_separator ( buffer : & mut StyledBuffer , line : usize , col : usize ) {
0 commit comments