]> git.parisson.com Git - pdf.js.git/commitdiff
Fix a bug and speed up graycs_getRgbBuffer.
authorKalervo Kujala <kkujala@>
Mon, 5 Sep 2011 20:11:48 +0000 (23:11 +0300)
committerKalervo Kujala <kkujala@>
Mon, 5 Sep 2011 20:11:48 +0000 (23:11 +0300)
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.

pdf.js

diff --git a/pdf.js b/pdf.js
index 7e748cfd8802fc7a18d1df6cc2ea750cddf7c1eb..9a476ccefa0c1d0f22065c26b671fe9a7149b5a1 100644 (file)
--- 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;