]> gitweb.factorcode.org Git - factor.git/commitdiff
documents: simplify text+loc.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Feb 2018 01:45:48 +0000 (17:45 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 13 Feb 2018 01:45:48 +0000 (17:45 -0800)
basis/documents/documents.factor

index 1de79f44742a2977ab4c798aeb00b535ce2893f2..be36fc462cd71b8bc3c8f5e46fb36bfed3025616 100644 (file)
@@ -77,14 +77,12 @@ CONSTANT: doc-start { 0 0 }
 : (doc-range) ( from to line# document -- slice )
     [ start/end-on-line ] 2keep doc-line <slice> ;
 
-: text+loc ( lines loc -- loc )
-    over [
-        over length 1 = [
-            nip first2
-        ] [
-            first swap length 1 - + 0
-        ] if
-    ] dip last length + 2array ;
+:: text+loc ( lines loc -- loc )
+    lines length 1 = [
+        loc first2
+    ] [
+        loc first lines length 1 - + 0
+    ] if lines last length + 2array ;
 
 : prepend-first ( str seq -- )
     0 swap [ append ] change-nth ;