From 4413ef40c229d5897426f6a83d812d5439d24597 Mon Sep 17 00:00:00 2001
From: Slava Pestov <slava@slava-pestovs-macbook-pro.local>
Date: Thu, 11 Sep 2008 20:01:10 -0500
Subject: [PATCH] Simplify mandelbrot

---
 extra/benchmark/mandel/mandel.factor | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/extra/benchmark/mandel/mandel.factor b/extra/benchmark/mandel/mandel.factor
index 31df9e4e70..64a673c8ec 100755
--- a/extra/benchmark/mandel/mandel.factor
+++ b/extra/benchmark/mandel/mandel.factor
@@ -1,9 +1,8 @@
 ! Copyright (C) 2005, 2008 Slava Pestov.
 ! See http://factorcode.org/license.txt for BSD license.
-USING: arrays io kernel namespaces math math.functions
-math.order math.parser sequences byte-arrays byte-vectors
-io.files io.encodings.binary fry make benchmark.mandel.params
-benchmark.mandel.colors ;
+USING: io kernel math math.functions sequences prettyprint
+io.files io.encodings io.encodings.ascii io.encodings.binary fry
+benchmark.mandel.params benchmark.mandel.colors ;
 IN: benchmark.mandel
 
 : x-inc width  200000 zoom-fact * / ; inline
@@ -25,18 +24,14 @@ IN: benchmark.mandel
     [ color-map [ length mod ] keep nth ] [ B{ 0 0 0 } ] if* ; inline
 
 : render ( -- )
-    height [ width swap '[ _ c pixel color % ] each ] each ; inline
+    height [ width swap '[ _ c pixel color write ] each ] each ; inline
 
 : ppm-header ( -- )
-    "P6\n" % width # " " % height # "\n255\n" % ; inline
-
-: buf-size ( -- n ) width height * 3 * 100 + ; inline
-
-: mandel ( -- data )
-    buf-size <byte-vector>
-    [ building [ ppm-header render ] with-variable ] [ B{ } like ] bi ;
+    ascii encode-output
+    "P6\n" write width pprint " " write height pprint "\n255\n" write
+    binary encode-output ; inline
 
 : mandel-main ( -- )
-    mandel "mandel.ppm" temp-file binary set-file-contents ;
+    "mandel.ppm" temp-file binary [ ppm-header render ] with-file-writer ;
 
 MAIN: mandel-main