2
1
mirror of https://github.com/qpdf/qpdf.git synced 2025-02-08 22:58:25 +00:00

eliminate extraneous allocations by not calling makeDirect when we

know an object is already direct


git-svn-id: svn+q:///qpdf/trunk@972 71b93d88-0707-0410-a8cf-f5a4172ac649
This commit is contained in:
Jay Berkenbilt 2010-06-05 21:00:05 +00:00
parent eef7154412
commit bf75e208e9

View File

@ -103,11 +103,14 @@ QPDF::flattenScalarReferences()
{ {
QPDFObjectHandle oh = node.getArrayItem(i); QPDFObjectHandle oh = node.getArrayItem(i);
if (oh.isScalar()) if (oh.isScalar())
{
if (oh.isIndirect())
{ {
QTC::TC("qpdf", "QPDF opt flatten array scalar"); QTC::TC("qpdf", "QPDF opt flatten array scalar");
oh.makeDirect(); oh.makeDirect();
node.setArrayItem(i, oh); node.setArrayItem(i, oh);
} }
}
else else
{ {
queue.push_back(oh); queue.push_back(oh);
@ -135,11 +138,14 @@ QPDF::flattenScalarReferences()
"INTERNAL ERROR: dictionary with null key found"); "INTERNAL ERROR: dictionary with null key found");
} }
else if (oh.isScalar()) else if (oh.isScalar())
{
if (oh.isIndirect())
{ {
QTC::TC("qpdf", "QPDF opt flatten dict scalar"); QTC::TC("qpdf", "QPDF opt flatten dict scalar");
oh.makeDirect(); oh.makeDirect();
dict.replaceKey(key, oh); dict.replaceKey(key, oh);
} }
}
else else
{ {
queue.push_back(oh); queue.push_back(oh);