From: Kalervo Kujala Date: Mon, 5 Sep 2011 21:11:24 +0000 (+0300) Subject: Fix a bug and speed up graycs_getRgbBuffer. X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=d4b8326496bdc65af50892df0cebe5ac897e7737;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 fifteen-fold in the firebug profile. --- diff --git a/pdf.js b/pdf.js index 9a476cc..44197b4 100644 --- a/pdf.js +++ b/pdf.js @@ -5469,8 +5469,9 @@ var DeviceGrayCS = (function() { }, getRgbBuffer: function graycs_getRgbBuffer(input, bits) { var scale = 255 / ((1 << bits) - 1); - var rgbBuf = new Uint8Array(input.length * 3); - for (var i = 0, j = 0; i < input.length; ++i) { + var length = input.length; + var rgbBuf = new Uint8Array(length * 3); + for (var i = 0, j = 0; i < length; ++i) { var c = (scale * input[i]) | 0; rgbBuf[j++] = c; rgbBuf[j++] = c;