From: Kalervo Kujala Date: Mon, 5 Sep 2011 20:11:48 +0000 (+0300) Subject: Fix a bug and speed up graycs_getRgbBuffer. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=80304b69761910a43a1281b042a424b237ee7681;p=pdf.js.git Fix a bug and speed up graycs_getRgbBuffer. An rgbBuffer was created which was three times as big as intended. It also caused that the function was very slow when rendering cable.pdf. Which led to a slow script warning dialog. With this fix the function speeds up ten-fold in the firebug profile. --- diff --git a/pdf.js b/pdf.js index 7e748cf..9a476cc 100644 --- a/pdf.js +++ b/pdf.js @@ -5469,9 +5469,8 @@ var DeviceGrayCS = (function() { }, getRgbBuffer: function graycs_getRgbBuffer(input, bits) { var scale = 255 / ((1 << bits) - 1); - var length = input.length * 3; - var rgbBuf = new Uint8Array(length); - for (var i = 0, j = 0; i < length; ++i) { + var rgbBuf = new Uint8Array(input.length * 3); + for (var i = 0, j = 0; i < input.length; ++i) { var c = (scale * input[i]) | 0; rgbBuf[j++] = c; rgbBuf[j++] = c;