From e40fd63bd39469b7780d9b96e433f6d016ef0e01 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 26 Mar 2017 13:53:13 +0200 Subject: [PATCH] In `src/core/evaluator.js`, convert a couple of `if (!someVariable) { error(...); }` instances to `assert(someVariable);` instead Rather than, in a number of places, basically duplicating the logic of `assert` we can simply utilize the function directly instead. --- src/core/evaluator.js | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 1b6377d8b..040c2840e 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -1071,14 +1071,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { case OPS.shadingFill: var shadingRes = resources.get('Shading'); - if (!shadingRes) { - error('No shading resource found'); - } + assert(shadingRes, 'No shading resource found'); var shading = shadingRes.get(args[0].name); - if (!shading) { - error('No shading object found'); - } + assert(shading, 'No shading object found'); var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler); @@ -2166,9 +2162,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // - set the type according to the descendant font // - get the FontDescriptor from the descendant font var df = dict.get('DescendantFonts'); - if (!df) { - error('Descendant fonts are not specified'); - } + assert(df, 'Descendant fonts are not specified'); dict = (isArray(df) ? xref.fetchIfRef(df[0]) : df); type = dict.get('Subtype'); @@ -2261,9 +2255,7 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { // FontDescriptor was not required. // This case is here for compatibility. var baseFontName = dict.get('BaseFont'); - if (!isName(baseFontName)) { - error('Base font is not specified'); - } + assert(isName(baseFontName), 'Base font is not specified'); // Using base font name as a font name. baseFontName = baseFontName.name.replace(/[,_]/g, '-');