]> gitweb.factorcode.org Git - factor.git/commitdiff
csv: faster for files that do not have blanks around delimiter.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 15 Jul 2012 16:15:55 +0000 (09:15 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 15 Jul 2012 16:15:55 +0000 (09:15 -0700)
basis/csv/csv.factor

index aa35264f12510718aa8e949fe8059bae2236a6bc..daddca9e25741164fd3d12b3ad2890fbc3638a0e 100644 (file)
@@ -28,7 +28,13 @@ MEMO: (quoted-field) ( delimiter -- delimiter' )
     delimiter> (quoted-field) read-until
     dup CHAR: " =
     [ 2drop quoted-field ]
-    [ swap [ blank? ] trim % ]
+    [
+        swap dup {
+            [ ?first blank? ]
+            [ ?last blank? ]
+        } 1||
+        [ [ blank? ] trim ] when %
+    ]
     if ;
 
 : maybe-escaped-quote ( -- endchar )