From 647274f118222cce978b3a79a50ad222d003d133 Mon Sep 17 00:00:00 2001 From: Albert Astals Cid Date: Sun, 27 Oct 2019 17:37:58 +0100 Subject: Introduce Object::getNumWithDefaultValue Is like getNum but instead of asserting if Object is not a num it returns the given default value I find it much easier to read rect->x1 = obj1.arrayGet(0).getNumWithDefaultValue(0); than (obj2 = obj1.arrayGet(0), obj2.isNum() ? rect->x1 = obj2.getNum() : rect->x1 = 0); On top of it has the benefit of being slightly faster --- poppler/Gfx.cc | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'poppler/Gfx.cc') diff --git a/poppler/Gfx.cc b/poppler/Gfx.cc index ec2b4b35..c5d47443 100644 --- a/poppler/Gfx.cc +++ b/poppler/Gfx.cc @@ -946,10 +946,8 @@ void Gfx::opSetDash(Object args[], int numArgs) { dash = nullptr; } else { dash = (double *)gmallocn(length, sizeof(double)); - bool dummyOk; for (i = 0; i < length; ++i) { - const Object obj = a->get(i); - dash[i] = obj.getNum(&dummyOk); + dash[i] = a->get(i).getNumWithDefaultValue(0); } } state->setLineDash(dash, length, args[1].getNum()); -- cgit v1.2.3