diff options
author | Albert Astals Cid <aacid@kde.org> | 2019-10-27 17:37:58 +0100 |
---|---|---|
committer | Albert Astals Cid <tsdgeos@yahoo.es> | 2019-10-30 21:34:31 +0000 |
commit | 647274f118222cce978b3a79a50ad222d003d133 (patch) | |
tree | af961d7ffee69b74b0bd8dba7564d073c6ac2e33 /poppler/Gfx.cc | |
parent | aa7827ab29377ef00c2dfbb16082617690375513 (diff) |
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
Diffstat (limited to 'poppler/Gfx.cc')
-rw-r--r-- | poppler/Gfx.cc | 4 |
1 files changed, 1 insertions, 3 deletions
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()); |