File tree Expand file tree Collapse file tree 2 files changed +23
-17
lines changed Expand file tree Collapse file tree 2 files changed +23
-17
lines changed Original file line number Diff line number Diff line change 1616#![ feature( min_specialization) ]  
1717#![ recursion_limit = "256" ]  
1818#![ feature( slice_internals) ]  
19+ #![ feature( stmt_expr_attributes) ]  
1920
2021#[ macro_use]  
2122extern  crate  rustc_macros; 
Original file line number Diff line number Diff line change @@ -56,25 +56,30 @@ impl LitKind {
5656                // new symbol because the string in the LitKind is different to the 
5757                // string in the token. 
5858                let  s = symbol. as_str ( ) ; 
59-                 let  symbol =
60-                     if  s. contains ( & [ '\\' ,  '\r' ] )  { 
61-                         let  mut  buf = String :: with_capacity ( s. len ( ) ) ; 
62-                         let  mut  error = Ok ( ( ) ) ; 
63-                         unescape_literal ( & s,  Mode :: Str ,  & mut  |_,  unescaped_char| { 
64-                             match  unescaped_char { 
65-                                 Ok ( c)  => buf. push ( c) , 
66-                                 Err ( err)  => { 
67-                                     if  err. is_fatal ( )  { 
68-                                         error = Err ( LitError :: LexerError ) ; 
69-                                     } 
59+                 let  symbol = if  s. contains ( & [ '\\' ,  '\r' ] )  { 
60+                     let  mut  buf = String :: with_capacity ( s. len ( ) ) ; 
61+                     let  mut  error = Ok ( ( ) ) ; 
62+                     // Force-inlining here is aggressive but the closure is 
63+                     // called on every char in the string, so it can be 
64+                     // hot in programs with many long strings. 
65+                     unescape_literal ( 
66+                         & s, 
67+                         Mode :: Str , 
68+                         & mut  #[ inline ( always) ] 
69+                         |_,  unescaped_char| match  unescaped_char { 
70+                             Ok ( c)  => buf. push ( c) , 
71+                             Err ( err)  => { 
72+                                 if  err. is_fatal ( )  { 
73+                                     error = Err ( LitError :: LexerError ) ; 
7074                                } 
7175                            } 
72-                         } ) ; 
73-                         error?; 
74-                         Symbol :: intern ( & buf) 
75-                     }  else  { 
76-                         symbol
77-                     } ; 
76+                         } , 
77+                     ) ; 
78+                     error?; 
79+                     Symbol :: intern ( & buf) 
80+                 }  else  { 
81+                     symbol
82+                 } ; 
7883                LitKind :: Str ( symbol,  ast:: StrStyle :: Cooked ) 
7984            } 
8085            token:: StrRaw ( n)  => { 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments