@@ -97,7 +97,7 @@ mod _sre {
9797 string : PyObjectRef ,
9898 #[ pyarg( any, default = "0" ) ]
9999 pos : usize ,
100- #[ pyarg( any, default = "std:: isize::MAX as usize" ) ]
100+ #[ pyarg( any, default = "isize::MAX as usize" ) ]
101101 endpos : usize ,
102102 }
103103
@@ -340,48 +340,42 @@ mod _sre {
340340 split_args : SplitArgs ,
341341 vm : & VirtualMachine ,
342342 ) -> PyResult < PyListRef > {
343- zelf. with_state (
344- split_args. string . clone ( ) ,
345- 0 ,
346- std:: usize:: MAX ,
347- vm,
348- |mut state| {
349- let mut splitlist: Vec < PyObjectRef > = Vec :: new ( ) ;
343+ zelf. with_state ( split_args. string . clone ( ) , 0 , usize:: MAX , vm, |mut state| {
344+ let mut splitlist: Vec < PyObjectRef > = Vec :: new ( ) ;
350345
351- let mut n = 0 ;
352- let mut last = 0 ;
353- while split_args. maxsplit == 0 || n < split_args. maxsplit {
354- state = state. search ( ) ;
355- if !state. has_matched {
356- break ;
357- }
346+ let mut n = 0 ;
347+ let mut last = 0 ;
348+ while split_args. maxsplit == 0 || n < split_args. maxsplit {
349+ state = state. search ( ) ;
350+ if !state. has_matched {
351+ break ;
352+ }
358353
359- /* get segment before this match */
360- splitlist. push ( slice_drive ( & state. string , last, state. start , vm) ) ;
354+ /* get segment before this match */
355+ splitlist. push ( slice_drive ( & state. string , last, state. start , vm) ) ;
361356
362- let m = Match :: new ( & state, zelf. clone ( ) , split_args. string . clone ( ) ) ;
357+ let m = Match :: new ( & state, zelf. clone ( ) , split_args. string . clone ( ) ) ;
363358
364- // add groups (if any)
365- for i in 1 ..zelf. groups + 1 {
366- splitlist. push (
367- m. get_slice ( i, state. string , vm)
368- . unwrap_or_else ( || vm. ctx . none ( ) ) ,
369- ) ;
370- }
371-
372- n += 1 ;
373- state. must_advance = state. string_position == state. start ;
374- last = state. string_position ;
375- state. start = state. string_position ;
376- state. reset ( ) ;
359+ // add groups (if any)
360+ for i in 1 ..zelf. groups + 1 {
361+ splitlist. push (
362+ m. get_slice ( i, state. string , vm)
363+ . unwrap_or_else ( || vm. ctx . none ( ) ) ,
364+ ) ;
377365 }
378366
379- // get segment following last match (even if empty)
380- splitlist. push ( slice_drive ( & state. string , last, state. string . count ( ) , vm) ) ;
367+ n += 1 ;
368+ state. must_advance = state. string_position == state. start ;
369+ last = state. string_position ;
370+ state. start = state. string_position ;
371+ state. reset ( ) ;
372+ }
381373
382- Ok ( PyList :: from ( splitlist) . into_ref ( vm) )
383- } ,
384- )
374+ // get segment following last match (even if empty)
375+ splitlist. push ( slice_drive ( & state. string , last, state. string . count ( ) , vm) ) ;
376+
377+ Ok ( PyList :: from ( splitlist) . into_ref ( vm) )
378+ } )
385379 }
386380
387381 #[ pymethod( magic) ]
@@ -477,7 +471,7 @@ mod _sre {
477471 }
478472 } ;
479473
480- zelf. with_state ( string. clone ( ) , 0 , std :: usize:: MAX , vm, |mut state| {
474+ zelf. with_state ( string. clone ( ) , 0 , usize:: MAX , vm, |mut state| {
481475 let mut sublist: Vec < PyObjectRef > = Vec :: new ( ) ;
482476 let mut n = 0 ;
483477 let mut last_pos = 0 ;
0 commit comments