1
Fork 0

auto merge of #15743 : Ryman/rust/mandelbrot_fix, r=alexcrichton

Matches the official sample output (N=200) again.

cc #15408
This commit is contained in:
bors 2014-07-18 21:46:32 +00:00
commit ef352faea8

View file

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