[Pkg-javascript-commits] [pdf.js] 166/246: Fixes searchRange calculation

David Prévot taffit at moszumanska.debian.org
Sun Sep 7 15:36:37 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository pdf.js.

commit ab8270ae3a4b43dfe4780eb76889a390cfc5334b
Author: Yury Delendik <ydelendik at mozilla.com>
Date:   Sun Aug 10 13:51:09 2014 -0500

    Fixes searchRange calculation
---
 src/core/fonts.js | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/src/core/fonts.js b/src/core/fonts.js
index eb1f5e9..fce7f8d 100644
--- a/src/core/fonts.js
+++ b/src/core/fonts.js
@@ -2224,21 +2224,6 @@ var IdentityToUnicodeMap = (function IdentityToUnicodeMapClosure() {
 })();
 
 var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {
-  function getMaxPower2(number) {
-    var maxPower = 0;
-    var value = number;
-    while (value >= 2) {
-      value /= 2;
-      maxPower++;
-    }
-
-    value = 2;
-    for (var i = 1; i < maxPower; i++) {
-      value *= 2;
-    }
-    return value;
-  }
-
   function writeInt16(dest, offset, num) {
     dest[offset] = (num >> 8) & 0xFF;
     dest[offset + 1] = num & 0xFF;
@@ -2274,10 +2259,15 @@ var OpenTypeFileBuilder = (function OpenTypeFileBuilderClosure() {
 
   OpenTypeFileBuilder.getSearchParams =
       function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
-    var searchRange = getMaxPower2(entriesCount) * entrySize;
+    var maxPower2 = 1, log2 = 0;
+    while ((maxPower2 ^ entriesCount) > maxPower2) {
+      maxPower2 <<= 1;
+      log2++;
+    }
+    var searchRange = maxPower2 * entrySize;
     return {
       range: searchRange,
-      entry: (Math.log(entriesCount) / Math.log(2)) | 0,
+      entry: log2,
       rangeShift: entrySize * entriesCount - searchRange
     };
   };

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git



More information about the Pkg-javascript-commits mailing list