]> git.parisson.com Git - pdf.js.git/commitdiff
Fix a bug and speed up graycs_getRgbBuffer.
authorKalervo Kujala <kkujala@>
Mon, 5 Sep 2011 21:11:24 +0000 (00:11 +0300)
committerKalervo Kujala <kkujala@>
Mon, 5 Sep 2011 21:11:24 +0000 (00: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 fifteen-fold in the firebug profile.

pdf.js

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