 : read-int ( -- n )
     4 read le> ;
 
+: read-ints ( n -- parts )
+    [ read-int ] replicate ;
+
 : read-double ( -- n )
     8 read le> bits>double ;
 
+: read-doubles ( n -- array )
+    [ read-double ] replicate ;
+
 : read-box ( -- box )
-    4 [ read-double ] replicate ;
-
-: read-ints ( n -- parts )
-    [ read-int ] replicate ;
+    4 read-doubles ;
 
 : read-range ( -- range )
-    read-double read-double 2array ;
-
-: read-doubles ( n -- array )
-    [ read-double ] replicate ;
+    2 read-doubles ;
 
 PRIVATE>
 

TUPLE: polygon-z box parts points z-range z-array m-range
m-array ;

: read-polygon-z ( -- polyline-z )
    read-box read-int read-int [ read-ints ] dip
    [ read-points read-range ]
    [ read-doubles read-range ]


TUPLE: polygon-m box parts points m-range m-array ;

: read-polygon-m ( -- polygon-m )
    read-box read-int read-int [ read-ints ] dip
    [ read-points read-range ] [ read-doubles ] bi
    polygon-m boa ;
