]> git.parisson.com Git - pdf.js.git/commitdiff
Remove unreachable logic after error(...) is called.
authorKalervo Kujala <kkujala@com>
Tue, 20 Mar 2012 12:16:48 +0000 (14:16 +0200)
committerKalervo Kujala <kkujala@com>
Tue, 20 Mar 2012 12:16:48 +0000 (14:16 +0200)
The function error(...) always throws so there is no need to return separately
or have an else branch.

src/crypto.js
src/fonts.js
src/obj.js
src/parser.js
src/pattern.js

index 7c34a850609baf54ea447b9696da3cdf743dfc12..b1a298223d37e78f55147d8fb5aa8abe7b49deb7 100644 (file)
@@ -570,7 +570,6 @@ var CipherTransformFactory = (function CipherTransformFactoryClosure() {
       };
     }
     error('Unknown crypto method');
-    return null;
   }
 
   CipherTransformFactory.prototype = {
index fed11c61f00b6daec3b913ea9ed60e91de9e3ba6..c1023f6fca800f3aed5fa08f8827972d1ad9f877 100644 (file)
@@ -494,10 +494,8 @@ var FontLoader = {
       // 82402.
 
       // Validate the names parameter -- the values can used to construct HTML.
-      if (!/^\w+$/.test(names.join(''))) {
+      if (!/^\w+$/.test(names.join('')))
         error('Invalid font name(s): ' + names.join());
-        return; // Keep the return in case if error() did not throw.
-      }
 
       var div = document.createElement('div');
       div.setAttribute('style',
index c38f922e514a22945a9147c56f17d8fa6f69f467..3c649fb068ef5a2ae09ddbe3d49472ab660242ec 100644 (file)
@@ -514,7 +514,6 @@ var XRef = (function XRefClosure() {
         return dict;
       // nothing helps
       error('Invalid PDF structure');
-      return null;
     },
     readXRef: function readXref(startXRef) {
       var stream = this.stream;
@@ -723,12 +722,10 @@ var PDFObjects = (function PDFObjectsClosure() {
 
       // If there isn't an object yet or the object isn't resolved, then the
       // data isn't ready yet!
-      if (!obj || !obj.isResolved) {
+      if (!obj || !obj.isResolved)
         error('Requesting object that isn\'t resolved yet ' + objId);
-        return null;
-      } else {
-        return obj.data;
-      }
+
+      return obj.data;
     },
 
     /**
index fc8f5bc66bb530bf4c5ced268a0eab802bca8029..fad8b2c035065b3a8a5d7525429fdb7240e4ccd9 100644 (file)
@@ -53,15 +53,14 @@ var Parser = (function ParserClosure() {
         this.shift();
         var dict = new Dict();
         while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
-          if (!isName(this.buf1)) {
+          if (!isName(this.buf1))
             error('Dictionary key must be a name object');
-          } else {
-            var key = this.buf1.name;
-            this.shift();
-            if (isEOF(this.buf1))
-              break;
-            dict.set(key, this.getObj(cipherTransform));
-          }
+
+          var key = this.buf1.name;
+          this.shift();
+          if (isEOF(this.buf1))
+            break;
+          dict.set(key, this.getObj(cipherTransform));
         }
         if (isEOF(this.buf1))
           error('End of file inside dictionary');
@@ -106,15 +105,14 @@ var Parser = (function ParserClosure() {
       // parse dictionary
       var dict = new Dict();
       while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
-        if (!isName(this.buf1)) {
+        if (!isName(this.buf1))
           error('Dictionary key must be a name object');
-        } else {
-          var key = this.buf1.name;
-          this.shift();
-          if (isEOF(this.buf1))
-            break;
-          dict.set(key, this.getObj(cipherTransform));
-        }
+
+        var key = this.buf1.name;
+        this.shift();
+        if (isEOF(this.buf1))
+          break;
+        dict.set(key, this.getObj(cipherTransform));
       }
 
       // parse image stream
@@ -176,10 +174,8 @@ var Parser = (function ParserClosure() {
 
       // get length
       var length = this.fetchIfRef(dict.get('Length'));
-      if (!isInt(length)) {
+      if (!isInt(length))
         error('Bad ' + length + ' attribute in stream');
-        length = 0;
-      }
 
       // skip over the stream data
       stream.pos = pos + length;
@@ -208,14 +204,13 @@ var Parser = (function ParserClosure() {
           filter = filterArray[i];
           if (!isName(filter))
             error('Bad filter name: ' + filter);
-          else {
-            params = null;
-            if (isArray(paramsArray) && (i in paramsArray))
-              params = paramsArray[i];
-            stream = this.makeFilter(stream, filter.name, length, params);
-            // after the first stream the length variable is invalid
-            length = null;
-          }
+
+          params = null;
+          if (isArray(paramsArray) && (i in paramsArray))
+            params = paramsArray[i];
+          stream = this.makeFilter(stream, filter.name, length, params);
+          // after the first stream the length variable is invalid
+          length = null;
         }
       }
       return stream;
@@ -527,17 +522,15 @@ var Lexer = (function LexerClosure() {
         // fall through
         case ')':
           error('Illegal character: ' + ch);
-          return Error;
       }
 
       // command
       var str = ch;
       while (!!(ch = stream.lookChar()) && !specialChars[ch.charCodeAt(0)]) {
         stream.skip();
-        if (str.length == 128) {
+        if (str.length == 128)
           error('Command token too long: ' + str.length);
-          break;
-        }
+
         str += ch;
       }
       if (str == 'true')
@@ -594,7 +587,6 @@ var Linearization = (function LinearizationClosure() {
         return obj;
       }
       error('"' + name + '" field in linearization table is invalid');
-      return 0;
     },
     getHint: function linearizationGetHint(index) {
       var linDict = this.linDict;
@@ -607,7 +599,6 @@ var Linearization = (function LinearizationClosure() {
         return obj2;
       }
       error('Hints table in linearization table is invalid: ' + index);
-      return 0;
     },
     get length() {
       if (!isDict(this.linDict))
index 3953161c192a4f22188e5932f33c799c2729ce7e..80ba159e71c3faf1360d08b17364100468e7e97d 100644 (file)
@@ -82,7 +82,7 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
     fnObj = xref.fetchIfRef(fnObj);
     if (isArray(fnObj))
       error('No support for array of functions');
-    else if (!isPDFFunction(fnObj))
+    if (!isPDFFunction(fnObj))
       error('Invalid function');
     var fn = PDFFunction.parse(xref, fnObj);