splitting: slightly faster string-lines.

db4
John Benediktsson 2012-07-13 20:26:07 -07:00
parent 5f77fe82f0
commit da692ff7ec
1 changed files with 9 additions and 2 deletions

View File

@ -104,8 +104,15 @@ GENERIC: string-lines ( str -- seq )
M: string string-lines
dup crlf? [
"\n" split
[ but-last-slice [ "\r" ?tail drop "\r" split ] map! drop ]
[ [ length 1 - ] keep [ "\r" split ] change-nth ]
[
but-last-slice [
dup ?last CHAR: \r = [ but-last ] when
[ CHAR: \r = ] split-when
] map! drop
] [
[ length 1 - ] keep
[ [ CHAR: \r = ] split-when ] change-nth
]
[ concat ]
tri
] [