Skip to content

Introduce Object::getNumWithDefaultValue

Albert Astals Cid requested to merge aacid/poppler:getNumWithDefaultValue into master

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

Edited by Albert Astals Cid

Merge request reports