]> gitweb.factorcode.org Git - factor.git/commitdiff
json.reader: less declare/unsafe.
authorJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Dec 2021 03:15:44 +0000 (19:15 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Wed, 22 Dec 2021 03:15:44 +0000 (19:15 -0800)
basis/json/reader/reader.factor

index afb5188a92a6cd78a9a6ec148488d6fcfd2328c6..b021f1a84dc6c1156e03a44b9ce7dc70100f36eb 100644 (file)
@@ -65,7 +65,7 @@ DEFER: (read-json-string)
 
 : read-json-string ( stream -- str )
     "\\\"" over stream-read-until CHAR: \" =
-    [ nip ] [ >sbuf (read-json-escape) { sbuf } declare "" like ] if ;
+    [ nip ] [ >sbuf (read-json-escape) "" like ] if ;
 
 : second-last-unsafe ( seq -- second-last )
     [ length 2 - ] [ nth-unsafe ] bi ; inline
@@ -77,38 +77,28 @@ DEFER: (read-json-string)
     [ dup length ] [ >= ] bi* [ json-error ] unless ; inline
 
 : v-over-push ( accum -- accum )
-    { vector } declare 2 check-length
-    dup [ pop-unsafe ] [ last-unsafe ] bi
-    { vector } declare push ;
+    2 check-length dup [ pop-unsafe ] [ last-unsafe ] bi push ;
 
 : v-pick-push ( accum -- accum )
-    { vector } declare 3 check-length dup
-    [ pop-unsafe ] [ second-last-unsafe ] bi
-    { vector } declare push ;
-
-: v-pop ( accum -- vector )
-    pop { vector } declare ; inline
+    3 check-length dup [ pop-unsafe ] [ second-last-unsafe ] bi push ;
 
 : v-close ( accum -- accum )
-    { vector } declare
-    dup last V{ } = not [ v-over-push ] when
-    { vector } declare ; inline
+    dup last V{ } = not [ v-over-push ] when ;
 
 : json-open-array ( accum -- accum )
-    { vector } declare V{ } clone suffix! ;
+    V{ } clone suffix! ;
 
 : json-open-hash ( accum -- accum )
-    { vector } declare V{ } clone suffix! V{ } clone suffix! ;
+    V{ } clone suffix! V{ } clone suffix! ;
 
 : json-close-array ( accum -- accum )
-    v-close dup v-pop { } like suffix! ;
+    v-close dup pop { } like suffix! ;
 
 : json-close-hash ( accum -- accum )
-    v-close dup dup [ v-pop ] bi@ swap H{ } zip-as suffix! ;
+    v-close dup dup [ pop ] bi@ swap H{ } zip-as suffix! ;
 
 : scan ( stream accum char -- stream accum )
     ! 2dup 1string swap . . ! Great for debug...
-    { object vector object } declare
     {
         { CHAR: \" [ over read-json-string suffix! ] }
         { CHAR: [  [ 1 json-depth +@ json-open-array ] }