From 2d51bce941c631c4aaf531711f3ff9c465c96e78 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Tue, 24 Jul 2018 14:31:06 +0200 Subject: [PATCH] Remove unnecessary `stream.length` check from `PDFDocument.linearization` Note first of all that `PDFDocument` will be initialized with either a `Stream` or a `ChunkedStream`, and that both of these have `length` getters. Secondly, the `PDFDocument` constructor will assert that the `stream` has a non-zero (and positive) length. Hence there's no point in checking `stream.length` in the `linearization` getter. --- src/core/document.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/core/document.js b/src/core/document.js index 675e9c1a6..6832ef2d6 100644 --- a/src/core/document.js +++ b/src/core/document.js @@ -424,16 +424,14 @@ var PDFDocument = (function PDFDocumentClosure() { }, get linearization() { - var linearization = null; - if (this.stream.length) { - try { - linearization = Linearization.create(this.stream); - } catch (err) { - if (err instanceof MissingDataException) { - throw err; - } - info(err); + let linearization = null; + try { + linearization = Linearization.create(this.stream); + } catch (err) { + if (err instanceof MissingDataException) { + throw err; } + info(err); } // shadow the prototype getter with a data property return shadow(this, 'linearization', linearization);