File tree Expand file tree Collapse file tree 1 file changed +5
-9
lines changed
Expand file tree Collapse file tree 1 file changed +5
-9
lines changed Original file line number Diff line number Diff line change @@ -227,20 +227,16 @@ pub enum TabElement {
227227fn numeric ( s : & str ) -> Result < ( & str , u8 ) , & str > {
228228 let bytes = s. as_bytes ( ) ;
229229 let mut i = 0 ;
230- while i < bytes. len ( ) && matches ! ( bytes[ i] , 48 ..=58 ) {
230+ let mut sum = 0 ;
231+ while i < bytes. len ( ) && bytes[ i] . is_ascii_digit ( ) {
232+ sum *= 10 ;
233+ sum += bytes[ i] - b'0' ;
231234 i += 1 ;
232235 }
233236 if i == 0 {
234237 return Err ( s) ;
235238 } ;
236- let parsed: u8 = bytes[ 0 ..i]
237- . iter ( )
238- . rev ( )
239- . map ( |x| x - 48 )
240- . enumerate ( )
241- . map ( |( idx, x) | 10u8 . pow ( idx as u32 ) * x)
242- . sum ( ) ;
243- Ok ( ( & s[ i..] , parsed) )
239+ Ok ( ( & s[ i..] , sum) )
244240}
245241
246242fn tab_element ( s : & str , set_bend_target : impl FnOnce ( u8 ) ) -> Result < ( & str , TabElement ) , & str > {
You can’t perform that action at this time.
0 commit comments