[Pkg-javascript-commits] [pdf.js] 62/157: Slightly more efficient `getDestination`

David Prévot taffit at moszumanska.debian.org
Tue Aug 11 06:46:36 UTC 2015


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

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

commit 7df78f997ec67e6e3810b14d57669c1fb97861e1
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date:   Wed Jul 8 15:31:06 2015 +0200

    Slightly more efficient `getDestination`
    
    For named destinations that are contained in a `Dict`, as opposed to a `NameTree`, we currently iterate through the *entire* dictionary just to fetch *one* destination.
    This code appears to simply have been copy-pasted from the `get destinations` method, but in its current form it's quite unnecessary/inefficient since can just get the required destination directly instead.
---
 src/core/obj.js | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/src/core/obj.js b/src/core/obj.js
index bcb9c90..f2bfdb6 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -493,17 +493,11 @@ var Catalog = (function CatalogClosure() {
         nameDictionaryRef = this.catDict.get('Dests');
       }
 
-      if (nameDictionaryRef) {
-        // reading simple destination dictionary
-        obj = nameDictionaryRef;
-        obj.forEach(function catalogForEach(key, value) {
-          if (!value) {
-            return;
-          }
-          if (key === destinationId) {
-            dest = fetchDestination(value);
-          }
-        });
+      if (nameDictionaryRef) { // Simple destination dictionary.
+        var value = nameDictionaryRef.get(destinationId);
+        if (value) {
+          dest = fetchDestination(value);
+        }
       }
       if (nameTreeRef) {
         var nameTree = new NameTree(nameTreeRef, xref);

-- 
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