]> git.lizzy.rs Git - rust.git/commitdiff
mandelbrot: fix overlapping buffers
authorKevin Butler <haqkrs@gmail.com>
Sun, 13 Jul 2014 22:52:11 +0000 (23:52 +0100)
committerKevin Butler <haqkrs@gmail.com>
Sun, 13 Jul 2014 22:52:11 +0000 (23:52 +0100)
src/test/bench/shootout-mandelbrot.rs

index 2d98668496cdb52e08c17a2a7d201ce41914106a..b0e23983192f23a8aaf0ae6a20aa6445e056fb22 100644 (file)
@@ -64,7 +64,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
     let chunk_size = h / WORKERS;
 
     // Account for remainders in workload division, e.g. 1000 / 16 = 62.5
-    let first_chunk_size = if h % WORKERS != 0 {
+    let last_chunk_size = if h % WORKERS != 0 {
         chunk_size + h % WORKERS
     } else {
         chunk_size
@@ -87,8 +87,8 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
             let mut is = Vec::with_capacity(w / WORKERS);
 
             let start = i * chunk_size;
-            let end = if i == 0 {
-                first_chunk_size
+            let end = if i == (WORKERS - 1) {
+                start + last_chunk_size
             } else {
                 (i + 1) * chunk_size
             };