]> gitweb.factorcode.org Git - factor.git/commitdiff
Use tr instead of substitute in a few places
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 10 Jul 2008 00:43:46 +0000 (19:43 -0500)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Thu, 10 Jul 2008 00:43:46 +0000 (19:43 -0500)
extra/io/windows/nt/files/files.factor
extra/json/writer/writer.factor
extra/sequences/lib/lib.factor
extra/tools/disassembler/disassembler.factor
extra/tools/vocabs/monitor/monitor.factor
extra/ui/commands/commands.factor
extra/unicode/data/data.factor

index 2a39cea4791701a739cac98381862350179621eb..6a890f63922b57a33b212d94ec4e86fd061dc6f1 100755 (executable)
@@ -4,7 +4,7 @@ io.windows.nt.backend windows windows.kernel32
 kernel libc math threads system
 alien.c-types alien.arrays alien.strings sequences combinators
 combinators.short-circuit ascii splitting alien strings
-assocs namespaces io.files.private accessors ;
+assocs namespaces io.files.private accessors tr ;
 IN: io.windows.nt.files
 
 M: winnt cwd
@@ -40,9 +40,11 @@ ERROR: not-absolute-path ;
         unicode-prefix prepend
     ] unless ;
 
+TR: normalize-separators "/" "\\" ;
+
 M: winnt normalize-path ( string -- string' )
     (normalize-path)
-    { { CHAR: / CHAR: \\ } } substitute
+    normalize-separators
     prepend-prefix ;
 
 M: winnt CreateFile-flags ( DWORD -- DWORD )
index a68c65087ea149e840d8cda31d11c1e7bdc7d840..0d22494b13c7abdd62685293133f8d3e32cc634d 100644 (file)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: kernel io.streams.string io strings splitting sequences math 
        math.parser assocs classes words namespaces prettyprint
-       hashtables mirrors ;
+       hashtables mirrors tr ;
 IN: json.writer
 
 #! Writes the object out to a stream in JSON format
@@ -24,10 +24,7 @@ M: number json-print ( num -- )
 M: sequence json-print ( array -- ) 
   CHAR: [ write1 [ >json ] map "," join write CHAR: ] write1 ;
 
-: jsvar-encode ( string -- string )
-  #! Convert the string so that it contains characters usable within
-  #! javascript variable names.
-  { { CHAR: - CHAR: _ } } substitute ;
+TR: jsvar-encode "-" "_" ;
   
 : tuple>fields ( object -- seq )
   <mirror> [
index 90bca7cef9705cc52107d373ca9f95da53b37865..0049320b94c453d050499267a8122333ccda6923 100755 (executable)
@@ -210,9 +210,6 @@ PRIVATE>
 : nths ( seq indices -- seq' )
     swap [ nth ] curry map ;
 
-: replace ( str oldseq newseq -- str' )
-    zip >hashtable substitute ;
-
 : remove-nth ( seq n -- seq' )
     cut-slice rest-slice append ;
 
index a7d9da4840823ec769da209c95fc4ddf5a8e558b..4a345e2345c0dbee9fc2a57b8b1a4df6b4f44d7e 100755 (executable)
@@ -3,7 +3,7 @@
 USING: io.files io words alien kernel math.parser alien.syntax
 io.launcher system assocs arrays sequences namespaces qualified
 system math generator.fixup io.encodings.ascii accessors
-generic ;
+generic tr ;
 IN: tools.disassembler
 
 : in-file ( -- path ) "gdb-in.txt" temp-file ;
@@ -36,8 +36,7 @@ M: method-spec make-disassemble-cmd
     try-process
     out-file ascii file-lines ;
 
-: tabs>spaces ( str -- str' )
-    { { CHAR: \t CHAR: \s } } substitute ;
+TR: tabs>spaces "\t" "\s" ;
 
 : disassemble ( obj -- )
     make-disassemble-cmd run-gdb
index ee5198a8f44f2e3eb4372f731291efb6ecdeae4e..12b2e41d3650809fc680e2e6fcd0bc4c9df82577 100755 (executable)
@@ -2,12 +2,16 @@
 ! See http://factorcode.org/license.txt for BSD license.\r
 USING: threads io.files io.monitors init kernel\r
 vocabs vocabs.loader tools.vocabs namespaces continuations\r
-sequences splitting assocs command-line concurrency.messaging io.backend sets ;\r
+sequences splitting assocs command-line concurrency.messaging\r
+io.backend sets tr ;\r
 IN: tools.vocabs.monitor\r
 \r
+TR: convert-separators "/\\" ".." ;\r
+\r
 : vocab-dir>vocab-name ( path -- vocab )\r
-    left-trim-separators right-trim-separators\r
-    { { CHAR: / CHAR: . } { CHAR: \\ CHAR: . } } substitute ;\r
+    left-trim-separators\r
+    right-trim-separators\r
+    convert-separators ;\r
 \r
 : path>vocab-name ( path -- vocab )\r
     dup ".factor" tail? [ parent-directory ] when ;\r
index 6a5a4d2c4225b25ebfc461076c4c702895f157f8..39eed24ada654f961a788a58c02d76e5f106d277 100755 (executable)
@@ -2,7 +2,7 @@
 ! See http://factorcode.org/license.txt for BSD license.
 USING: accessors arrays definitions kernel sequences strings
 math assocs words generic namespaces assocs quotations splitting
-ui.gestures unicode.case unicode.categories ;
+ui.gestures unicode.case unicode.categories tr ;
 IN: ui.commands
 
 SYMBOL: +nullary+
@@ -50,8 +50,10 @@ GENERIC: command-word ( command -- word )
     swap pick commands set-at
     update-gestures ;
 
+TR: convert-command-name "-" " " ;
+
 : (command-name) ( string -- newstring )
-    { { CHAR: - CHAR: \s } } substitute >title ;
+    convert-command-name >title ;
 
 M: word command-name ( word -- str )
     name>> 
index f74e2e0473d643149401c845f88f2b67fbfc5204..fdcf495307724dc3ae4d9a28631170d86f1d2f54 100755 (executable)
@@ -125,7 +125,7 @@ VALUE: properties
 : process-names ( data -- names-hash )
     1 swap (process-data) [
         ascii-lower { { CHAR: \s CHAR: - } } substitute swap
-    ] assoc-map >hashtable ;
+    ] H{ } assoc-map-as ;
 
 : multihex ( hexstring -- string )
     " " split [ hex> ] map sift ;