File tree Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Expand file tree Collapse file tree 1 file changed +10
-21
lines changed Original file line number Diff line number Diff line change @@ -461,27 +461,16 @@ position C<pos>.
461
461
}
462
462
463
463
our method split_words (str $ words ) {
464
- Q : PIR {
465
- .include 'src/Regex/constants.pir'
466
- .local string words
467
- words = find_lex '$words'
468
- .local int pos, eos
469
- .local pmc result
470
- pos = 0
471
- eos = length words
472
- result = new ['ResizablePMCArray']
473
- split_loop :
474
- pos = find_not_cclass . CCLASS_WHITESPACE, words , pos , eos
475
- unless pos < eos goto split_done
476
- $ I0 = find_cclass . CCLASS_WHITESPACE, words , pos , eos
477
- $ I1 = $ I0 - pos
478
- $ S0 = substr words , pos , $ I1
479
- push result, $ S0
480
- pos = $ I0
481
- goto split_loop
482
- split_done:
483
- . return (result)
484
- };
464
+ my @ result ;
465
+ my int $ pos := 0 ;
466
+ my int $ eos := nqp :: chars ($ words );
467
+ my int $ ws ;
468
+ while ($ pos := nqp ::findnotcclass(pir::const::CCLASS_WHITESPACE, $ words , $ pos , $ eos )) < $ eos {
469
+ $ ws := nqp ::findcclass(pir::const::CCLASS_WHITESPACE, $ words , $ pos , $ eos );
470
+ nqp :: push (@ result , nqp :: substr ($ words , $ pos , $ ws - $ pos ));
471
+ $ pos := $ ws ;
472
+ }
473
+ @ result
485
474
}
486
475
487
476
= begin
You can’t perform that action at this time.
0 commit comments