From da692ff7ecb2331b1b8d3748557a334a766ab21a Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Fri, 13 Jul 2012 20:26:07 -0700 Subject: [PATCH] splitting: slightly faster string-lines. --- core/splitting/splitting.factor | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/core/splitting/splitting.factor b/core/splitting/splitting.factor index 305e06c467..69a66eb5fd 100644 --- a/core/splitting/splitting.factor +++ b/core/splitting/splitting.factor @@ -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 ] [