Commit bf75e208e930a757c4d66e92e5594f422da8f935

Authored by Jay Berkenbilt
1 parent eef71544

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
Showing 1 changed file with 12 additions and 6 deletions
libqpdf/QPDF_optimization.cc
@@ -104,9 +104,12 @@ QPDF::flattenScalarReferences() @@ -104,9 +104,12 @@ QPDF::flattenScalarReferences()
104 QPDFObjectHandle oh = node.getArrayItem(i); 104 QPDFObjectHandle oh = node.getArrayItem(i);
105 if (oh.isScalar()) 105 if (oh.isScalar())
106 { 106 {
107 - QTC::TC("qpdf", "QPDF opt flatten array scalar");  
108 - oh.makeDirect();  
109 - node.setArrayItem(i, oh); 107 + if (oh.isIndirect())
  108 + {
  109 + QTC::TC("qpdf", "QPDF opt flatten array scalar");
  110 + oh.makeDirect();
  111 + node.setArrayItem(i, oh);
  112 + }
110 } 113 }
111 else 114 else
112 { 115 {
@@ -136,9 +139,12 @@ QPDF::flattenScalarReferences() @@ -136,9 +139,12 @@ QPDF::flattenScalarReferences()
136 } 139 }
137 else if (oh.isScalar()) 140 else if (oh.isScalar())
138 { 141 {
139 - QTC::TC("qpdf", "QPDF opt flatten dict scalar");  
140 - oh.makeDirect();  
141 - dict.replaceKey(key, oh); 142 + if (oh.isIndirect())
  143 + {
  144 + QTC::TC("qpdf", "QPDF opt flatten dict scalar");
  145 + oh.makeDirect();
  146 + dict.replaceKey(key, oh);
  147 + }
142 } 148 }
143 else 149 else
144 { 150 {