From 16911233da82601e2df6b0af49fc2136db38535d Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Fri, 6 Jan 2017 17:49:19 +0000 Subject: Fix /dev/null slowdown. In commit 80308eae9964e71b66a18f3de6ebcd2ebf0d306b ("Regularize band writer interface"), I inadvertently slowed down outputting to /dev/null. Fixed here. Also take the opportunity to speed ppm/pnm files writing in general if we don't need to collate. --- source/fitz/output-pnm.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'source/fitz/output-pnm.c') diff --git a/source/fitz/output-pnm.c b/source/fitz/output-pnm.c index 3a605524..68f25bcb 100644 --- a/source/fitz/output-pnm.c +++ b/source/fitz/output-pnm.c @@ -39,6 +39,9 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta if (n-alpha != 1 && n-alpha != 3) fz_throw(ctx, FZ_ERROR_GENERIC, "pixmap must be grayscale or rgb to write as pnm"); + if (!out) + return; + if (end > h) end = h; end -= band_start; @@ -78,6 +81,9 @@ pnm_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta break; } case 3: + fz_write(ctx, out, p, num_written*3); + p += num_written*3; + break; case 4: { char *o = buffer; @@ -188,6 +194,9 @@ pam_write_band(fz_context *ctx, fz_band_writer *writer, int stride, int band_sta int y; int end = band_start + band_height; + if (!out) + return; + if (end > h) end = h; end -= band_start; -- cgit v1.2.3