Commit 89f19b709916ed26d7499761140549a02c36d3f5

Authored by Jay Berkenbilt
1 parent 31092dc6

Performance: remove Members indirection for QPDFObjectHandle

ChangeLog
  1 +2020-04-02 Jay Berkenbilt <ejb@ql.org>
  2 +
  3 + * Remove Members class indirection for QPDFObjectHandle. Those are
  4 + copied and assigned too often, and that change caused a very
  5 + substantial performance hit.
  6 +
1 7 2020-03-31 Jay Berkenbilt <ejb@ql.org>
2 8  
3 9 * When detecting unreferenced images during page splitting, if any
... ...
include/qpdf/QPDFObjectHandle.hh
... ... @@ -251,10 +251,10 @@ class QPDFObjectHandle
251 251 QPDF_DLL
252 252 QPDFObjectHandle();
253 253 QPDF_DLL
254   - QPDFObjectHandle(QPDFObjectHandle const&);
  254 + QPDFObjectHandle(QPDFObjectHandle const&) = default;
255 255 QPDF_DLL
256 256 QPDFObjectHandle&
257   - operator=(QPDFObjectHandle const&);
  257 + operator=(QPDFObjectHandle const&) = default;
258 258 QPDF_DLL
259 259 bool isInitialized() const;
260 260  
... ... @@ -957,7 +957,7 @@ class QPDFObjectHandle
957 957 static PointerHolder<QPDFObject> getObject(QPDFObjectHandle& o)
958 958 {
959 959 o.dereference();
960   - return o.m->obj;
  960 + return o.obj;
961 961 }
962 962 };
963 963 friend class ObjAccessor;
... ... @@ -1077,29 +1077,16 @@ class QPDFObjectHandle
1077 1077 std::string const& description, std::string& all_description);
1078 1078 static void warn(QPDF*, QPDFExc const&);
1079 1079  
1080   - class Members
1081   - {
1082   - friend class ObjAccessor;
1083   - friend class QPDFObjectHandle;
1084   -
1085   - public:
1086   - QPDF_DLL
1087   - ~Members();
  1080 + bool initialized;
1088 1081  
1089   - private:
1090   - Members();
1091   - Members(QPDF* qpdf, int objid, int generation);
1092   - Members(QPDFObject* data);
1093   -
1094   - bool initialized;
1095   -
1096   - QPDF* qpdf;
1097   - int objid; // 0 for direct object
1098   - int generation;
1099   - PointerHolder<QPDFObject> obj;
1100   - bool reserved;
1101   - };
1102   - PointerHolder<Members> m;
  1082 + // Moving members of QPDFObjectHandle into a smart pointer incurs
  1083 + // a substantial performance penalty since QPDFObjectHandle
  1084 + // objects are copied around so frequently.
  1085 + QPDF* qpdf;
  1086 + int objid; // 0 for direct object
  1087 + int generation;
  1088 + PointerHolder<QPDFObject> obj;
  1089 + bool reserved;
1103 1090 };
1104 1091  
1105 1092 #endif // QPDFOBJECTHANDLE_HH
... ...
libqpdf/QPDFObjectHandle.cc
... ... @@ -135,11 +135,7 @@ QPDFObjectHandle::ParserCallbacks::terminateParsing()
135 135 throw TerminateParsing();
136 136 }
137 137  
138   -QPDFObjectHandle::Members::~Members()
139   -{
140   -}
141   -
142   -QPDFObjectHandle::Members::Members() :
  138 +QPDFObjectHandle::QPDFObjectHandle() :
143 139 initialized(false),
144 140 qpdf(0),
145 141 objid(0),
... ... @@ -148,7 +144,7 @@ QPDFObjectHandle::Members::Members() :
148 144 {
149 145 }
150 146  
151   -QPDFObjectHandle::Members::Members(QPDF* qpdf, int objid, int generation) :
  147 +QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, int objid, int generation) :
152 148 initialized(true),
153 149 qpdf(qpdf),
154 150 objid(objid),
... ... @@ -157,7 +153,7 @@ QPDFObjectHandle::Members::Members(QPDF* qpdf, int objid, int generation) :
157 153 {
158 154 }
159 155  
160   -QPDFObjectHandle::Members::Members(QPDFObject* data) :
  156 +QPDFObjectHandle::QPDFObjectHandle(QPDFObject* data) :
161 157 initialized(true),
162 158 qpdf(0),
163 159 objid(0),
... ... @@ -167,38 +163,6 @@ QPDFObjectHandle::Members::Members(QPDFObject* data) :
167 163 {
168 164 }
169 165  
170   -
171   -QPDFObjectHandle::QPDFObjectHandle() :
172   - m(new Members)
173   -{
174   -}
175   -
176   -QPDFObjectHandle::QPDFObjectHandle(QPDFObjectHandle const& rhs) :
177   - m(new Members)
178   -{
179   - *m = *rhs.m;
180   -}
181   -
182   -QPDFObjectHandle&
183   -QPDFObjectHandle::operator=(QPDFObjectHandle const& rhs)
184   -{
185   - if (this != &rhs)
186   - {
187   - *m = *rhs.m;
188   - }
189   - return *this;
190   -}
191   -
192   -QPDFObjectHandle::QPDFObjectHandle(QPDF* qpdf, int objid, int generation) :
193   - m(new Members(qpdf, objid, generation))
194   -{
195   -}
196   -
197   -QPDFObjectHandle::QPDFObjectHandle(QPDFObject* data) :
198   - m(new Members(data))
199   -{
200   -}
201   -
202 166 void
203 167 QPDFObjectHandle::releaseResolved()
204 168 {
... ... @@ -208,14 +172,14 @@ QPDFObjectHandle::releaseResolved()
208 172 // destruction. See comments in QPDF::~QPDF().
209 173 if (isIndirect())
210 174 {
211   - if (this->m->obj.getPointer())
  175 + if (this->obj.getPointer())
212 176 {
213   - this->m->obj = 0;
  177 + this->obj = 0;
214 178 }
215 179 }
216 180 else
217 181 {
218   - QPDFObject::ObjAccessor::releaseResolved(this->m->obj.getPointer());
  182 + QPDFObject::ObjAccessor::releaseResolved(this->obj.getPointer());
219 183 }
220 184 }
221 185  
... ... @@ -234,16 +198,16 @@ QPDFObjectHandle::setObjectDescriptionFromInput(
234 198 bool
235 199 QPDFObjectHandle::isInitialized() const
236 200 {
237   - return this->m->initialized;
  201 + return this->initialized;
238 202 }
239 203  
240 204 QPDFObject::object_type_e
241 205 QPDFObjectHandle::getTypeCode()
242 206 {
243   - if (this->m->initialized)
  207 + if (this->initialized)
244 208 {
245 209 dereference();
246   - return this->m->obj->getTypeCode();
  210 + return this->obj->getTypeCode();
247 211 }
248 212 else
249 213 {
... ... @@ -254,10 +218,10 @@ QPDFObjectHandle::getTypeCode()
254 218 char const*
255 219 QPDFObjectHandle::getTypeName()
256 220 {
257   - if (this->m->initialized)
  221 + if (this->initialized)
258 222 {
259 223 dereference();
260   - return this->m->obj->getTypeName();
  224 + return this->obj->getTypeName();
261 225 }
262 226 else
263 227 {
... ... @@ -283,35 +247,35 @@ bool
283 247 QPDFObjectHandle::isBool()
284 248 {
285 249 dereference();
286   - return QPDFObjectTypeAccessor<QPDF_Bool>::check(m->obj.getPointer());
  250 + return QPDFObjectTypeAccessor<QPDF_Bool>::check(obj.getPointer());
287 251 }
288 252  
289 253 bool
290 254 QPDFObjectHandle::isDirectNull() const
291 255 {
292   - return (this->m->initialized && (this->m->objid == 0) &&
293   - QPDFObjectTypeAccessor<QPDF_Null>::check(m->obj.getPointer()));
  256 + return (this->initialized && (this->objid == 0) &&
  257 + QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer()));
294 258 }
295 259  
296 260 bool
297 261 QPDFObjectHandle::isNull()
298 262 {
299 263 dereference();
300   - return QPDFObjectTypeAccessor<QPDF_Null>::check(m->obj.getPointer());
  264 + return QPDFObjectTypeAccessor<QPDF_Null>::check(obj.getPointer());
301 265 }
302 266  
303 267 bool
304 268 QPDFObjectHandle::isInteger()
305 269 {
306 270 dereference();
307   - return QPDFObjectTypeAccessor<QPDF_Integer>::check(m->obj.getPointer());
  271 + return QPDFObjectTypeAccessor<QPDF_Integer>::check(obj.getPointer());
308 272 }
309 273  
310 274 bool
311 275 QPDFObjectHandle::isReal()
312 276 {
313 277 dereference();
314   - return QPDFObjectTypeAccessor<QPDF_Real>::check(m->obj.getPointer());
  278 + return QPDFObjectTypeAccessor<QPDF_Real>::check(obj.getPointer());
315 279 }
316 280  
317 281 bool
... ... @@ -344,49 +308,49 @@ bool
344 308 QPDFObjectHandle::isName()
345 309 {
346 310 dereference();
347   - return QPDFObjectTypeAccessor<QPDF_Name>::check(m->obj.getPointer());
  311 + return QPDFObjectTypeAccessor<QPDF_Name>::check(obj.getPointer());
348 312 }
349 313  
350 314 bool
351 315 QPDFObjectHandle::isString()
352 316 {
353 317 dereference();
354   - return QPDFObjectTypeAccessor<QPDF_String>::check(m->obj.getPointer());
  318 + return QPDFObjectTypeAccessor<QPDF_String>::check(obj.getPointer());
355 319 }
356 320  
357 321 bool
358 322 QPDFObjectHandle::isOperator()
359 323 {
360 324 dereference();
361   - return QPDFObjectTypeAccessor<QPDF_Operator>::check(m->obj.getPointer());
  325 + return QPDFObjectTypeAccessor<QPDF_Operator>::check(obj.getPointer());
362 326 }
363 327  
364 328 bool
365 329 QPDFObjectHandle::isInlineImage()
366 330 {
367 331 dereference();
368   - return QPDFObjectTypeAccessor<QPDF_InlineImage>::check(m->obj.getPointer());
  332 + return QPDFObjectTypeAccessor<QPDF_InlineImage>::check(obj.getPointer());
369 333 }
370 334  
371 335 bool
372 336 QPDFObjectHandle::isArray()
373 337 {
374 338 dereference();
375   - return QPDFObjectTypeAccessor<QPDF_Array>::check(m->obj.getPointer());
  339 + return QPDFObjectTypeAccessor<QPDF_Array>::check(obj.getPointer());
376 340 }
377 341  
378 342 bool
379 343 QPDFObjectHandle::isDictionary()
380 344 {
381 345 dereference();
382   - return QPDFObjectTypeAccessor<QPDF_Dictionary>::check(m->obj.getPointer());
  346 + return QPDFObjectTypeAccessor<QPDF_Dictionary>::check(obj.getPointer());
383 347 }
384 348  
385 349 bool
386 350 QPDFObjectHandle::isStream()
387 351 {
388 352 dereference();
389   - return QPDFObjectTypeAccessor<QPDF_Stream>::check(m->obj.getPointer());
  353 + return QPDFObjectTypeAccessor<QPDF_Stream>::check(obj.getPointer());
390 354 }
391 355  
392 356 bool
... ... @@ -394,14 +358,14 @@ QPDFObjectHandle::isReserved()
394 358 {
395 359 // dereference will clear reserved if this has been replaced
396 360 dereference();
397   - return this->m->reserved;
  361 + return this->reserved;
398 362 }
399 363  
400 364 bool
401 365 QPDFObjectHandle::isIndirect()
402 366 {
403 367 assertInitialized();
404   - return (this->m->objid != 0);
  368 + return (this->objid != 0);
405 369 }
406 370  
407 371 bool
... ... @@ -418,7 +382,7 @@ QPDFObjectHandle::getBoolValue()
418 382 {
419 383 if (isBool())
420 384 {
421   - return dynamic_cast<QPDF_Bool*>(m->obj.getPointer())->getVal();
  385 + return dynamic_cast<QPDF_Bool*>(obj.getPointer())->getVal();
422 386 }
423 387 else
424 388 {
... ... @@ -435,7 +399,7 @@ QPDFObjectHandle::getIntValue()
435 399 {
436 400 if (isInteger())
437 401 {
438   - return dynamic_cast<QPDF_Integer*>(m->obj.getPointer())->getVal();
  402 + return dynamic_cast<QPDF_Integer*>(obj.getPointer())->getVal();
439 403 }
440 404 else
441 405 {
... ... @@ -528,7 +492,7 @@ QPDFObjectHandle::getRealValue()
528 492 {
529 493 if (isReal())
530 494 {
531   - return dynamic_cast<QPDF_Real*>(m->obj.getPointer())->getVal();
  495 + return dynamic_cast<QPDF_Real*>(obj.getPointer())->getVal();
532 496 }
533 497 else
534 498 {
... ... @@ -545,7 +509,7 @@ QPDFObjectHandle::getName()
545 509 {
546 510 if (isName())
547 511 {
548   - return dynamic_cast<QPDF_Name*>(m->obj.getPointer())->getName();
  512 + return dynamic_cast<QPDF_Name*>(obj.getPointer())->getName();
549 513 }
550 514 else
551 515 {
... ... @@ -562,7 +526,7 @@ QPDFObjectHandle::getStringValue()
562 526 {
563 527 if (isString())
564 528 {
565   - return dynamic_cast<QPDF_String*>(m->obj.getPointer())->getVal();
  529 + return dynamic_cast<QPDF_String*>(obj.getPointer())->getVal();
566 530 }
567 531 else
568 532 {
... ... @@ -577,7 +541,7 @@ QPDFObjectHandle::getUTF8Value()
577 541 {
578 542 if (isString())
579 543 {
580   - return dynamic_cast<QPDF_String*>(m->obj.getPointer())->getUTF8Val();
  544 + return dynamic_cast<QPDF_String*>(obj.getPointer())->getUTF8Val();
581 545 }
582 546 else
583 547 {
... ... @@ -594,7 +558,7 @@ QPDFObjectHandle::getOperatorValue()
594 558 {
595 559 if (isOperator())
596 560 {
597   - return dynamic_cast<QPDF_Operator*>(m->obj.getPointer())->getVal();
  561 + return dynamic_cast<QPDF_Operator*>(obj.getPointer())->getVal();
598 562 }
599 563 else
600 564 {
... ... @@ -609,7 +573,7 @@ QPDFObjectHandle::getInlineImageValue()
609 573 {
610 574 if (isInlineImage())
611 575 {
612   - return dynamic_cast<QPDF_InlineImage*>(m->obj.getPointer())->getVal();
  576 + return dynamic_cast<QPDF_InlineImage*>(obj.getPointer())->getVal();
613 577 }
614 578 else
615 579 {
... ... @@ -626,7 +590,7 @@ QPDFObjectHandle::getArrayNItems()
626 590 {
627 591 if (isArray())
628 592 {
629   - return dynamic_cast<QPDF_Array*>(m->obj.getPointer())->getNItems();
  593 + return dynamic_cast<QPDF_Array*>(obj.getPointer())->getNItems();
630 594 }
631 595 else
632 596 {
... ... @@ -642,7 +606,7 @@ QPDFObjectHandle::getArrayItem(int n)
642 606 QPDFObjectHandle result;
643 607 if (isArray() && (n < getArrayNItems()) && (n >= 0))
644 608 {
645   - result = dynamic_cast<QPDF_Array*>(m->obj.getPointer())->getItem(n);
  609 + result = dynamic_cast<QPDF_Array*>(obj.getPointer())->getItem(n);
646 610 }
647 611 else
648 612 {
... ... @@ -659,7 +623,7 @@ QPDFObjectHandle::getArrayItem(int n)
659 623 }
660 624 QPDF* context = 0;
661 625 std::string description;
662   - if (this->m->obj->getDescription(context, description))
  626 + if (this->obj->getDescription(context, description))
663 627 {
664 628 result.setObjectDescription(
665 629 context,
... ... @@ -755,7 +719,7 @@ QPDFObjectHandle::getArrayAsVector()
755 719 std::vector<QPDFObjectHandle> result;
756 720 if (isArray())
757 721 {
758   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->getAsVector(result);
  722 + dynamic_cast<QPDF_Array*>(obj.getPointer())->getAsVector(result);
759 723 }
760 724 else
761 725 {
... ... @@ -772,7 +736,7 @@ QPDFObjectHandle::setArrayItem(int n, QPDFObjectHandle const&amp; item)
772 736 {
773 737 if (isArray())
774 738 {
775   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->setItem(n, item);
  739 + dynamic_cast<QPDF_Array*>(obj.getPointer())->setItem(n, item);
776 740 }
777 741 else
778 742 {
... ... @@ -786,7 +750,7 @@ QPDFObjectHandle::setArrayFromVector(std::vector&lt;QPDFObjectHandle&gt; const&amp; items)
786 750 {
787 751 if (isArray())
788 752 {
789   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->setFromVector(items);
  753 + dynamic_cast<QPDF_Array*>(obj.getPointer())->setFromVector(items);
790 754 }
791 755 else
792 756 {
... ... @@ -800,7 +764,7 @@ QPDFObjectHandle::insertItem(int at, QPDFObjectHandle const&amp; item)
800 764 {
801 765 if (isArray())
802 766 {
803   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->insertItem(at, item);
  767 + dynamic_cast<QPDF_Array*>(obj.getPointer())->insertItem(at, item);
804 768 }
805 769 else
806 770 {
... ... @@ -814,7 +778,7 @@ QPDFObjectHandle::appendItem(QPDFObjectHandle const&amp; item)
814 778 {
815 779 if (isArray())
816 780 {
817   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->appendItem(item);
  781 + dynamic_cast<QPDF_Array*>(obj.getPointer())->appendItem(item);
818 782 }
819 783 else
820 784 {
... ... @@ -828,7 +792,7 @@ QPDFObjectHandle::eraseItem(int at)
828 792 {
829 793 if (isArray() && (at < getArrayNItems()) && (at >= 0))
830 794 {
831   - dynamic_cast<QPDF_Array*>(m->obj.getPointer())->eraseItem(at);
  795 + dynamic_cast<QPDF_Array*>(obj.getPointer())->eraseItem(at);
832 796 }
833 797 else
834 798 {
... ... @@ -852,7 +816,7 @@ QPDFObjectHandle::hasKey(std::string const&amp; key)
852 816 {
853 817 if (isDictionary())
854 818 {
855   - return dynamic_cast<QPDF_Dictionary*>(m->obj.getPointer())->hasKey(key);
  819 + return dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->hasKey(key);
856 820 }
857 821 else
858 822 {
... ... @@ -870,7 +834,7 @@ QPDFObjectHandle::getKey(std::string const&amp; key)
870 834 if (isDictionary())
871 835 {
872 836 result = dynamic_cast<QPDF_Dictionary*>(
873   - m->obj.getPointer())->getKey(key);
  837 + obj.getPointer())->getKey(key);
874 838 }
875 839 else
876 840 {
... ... @@ -880,7 +844,7 @@ QPDFObjectHandle::getKey(std::string const&amp; key)
880 844 result = newNull();
881 845 QPDF* qpdf = 0;
882 846 std::string description;
883   - if (this->m->obj->getDescription(qpdf, description))
  847 + if (this->obj->getDescription(qpdf, description))
884 848 {
885 849 result.setObjectDescription(
886 850 qpdf,
... ... @@ -898,7 +862,7 @@ QPDFObjectHandle::getKeys()
898 862 std::set<std::string> result;
899 863 if (isDictionary())
900 864 {
901   - result = dynamic_cast<QPDF_Dictionary*>(m->obj.getPointer())->getKeys();
  865 + result = dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->getKeys();
902 866 }
903 867 else
904 868 {
... ... @@ -915,7 +879,7 @@ QPDFObjectHandle::getDictAsMap()
915 879 if (isDictionary())
916 880 {
917 881 result = dynamic_cast<QPDF_Dictionary*>(
918   - m->obj.getPointer())->getAsMap();
  882 + obj.getPointer())->getAsMap();
919 883 }
920 884 else
921 885 {
... ... @@ -1082,7 +1046,7 @@ QPDF*
1082 1046 QPDFObjectHandle::getOwningQPDF()
1083 1047 {
1084 1048 // Will be null for direct objects
1085   - return this->m->qpdf;
  1049 + return this->qpdf;
1086 1050 }
1087 1051  
1088 1052 // Dictionary mutators
... ... @@ -1094,7 +1058,7 @@ QPDFObjectHandle::replaceKey(std::string const&amp; key,
1094 1058 if (isDictionary())
1095 1059 {
1096 1060 dynamic_cast<QPDF_Dictionary*>(
1097   - m->obj.getPointer())->replaceKey(key, value);
  1061 + obj.getPointer())->replaceKey(key, value);
1098 1062 }
1099 1063 else
1100 1064 {
... ... @@ -1108,7 +1072,7 @@ QPDFObjectHandle::removeKey(std::string const&amp; key)
1108 1072 {
1109 1073 if (isDictionary())
1110 1074 {
1111   - dynamic_cast<QPDF_Dictionary*>(m->obj.getPointer())->removeKey(key);
  1075 + dynamic_cast<QPDF_Dictionary*>(obj.getPointer())->removeKey(key);
1112 1076 }
1113 1077 else
1114 1078 {
... ... @@ -1124,7 +1088,7 @@ QPDFObjectHandle::replaceOrRemoveKey(std::string const&amp; key,
1124 1088 if (isDictionary())
1125 1089 {
1126 1090 dynamic_cast<QPDF_Dictionary*>(
1127   - m->obj.getPointer())->replaceOrRemoveKey(key, value);
  1091 + obj.getPointer())->replaceOrRemoveKey(key, value);
1128 1092 }
1129 1093 else
1130 1094 {
... ... @@ -1138,21 +1102,21 @@ QPDFObjectHandle
1138 1102 QPDFObjectHandle::getDict()
1139 1103 {
1140 1104 assertStream();
1141   - return dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->getDict();
  1105 + return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getDict();
1142 1106 }
1143 1107  
1144 1108 bool
1145 1109 QPDFObjectHandle::isDataModified()
1146 1110 {
1147 1111 assertStream();
1148   - return dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->isDataModified();
  1112 + return dynamic_cast<QPDF_Stream*>(obj.getPointer())->isDataModified();
1149 1113 }
1150 1114  
1151 1115 void
1152 1116 QPDFObjectHandle::replaceDict(QPDFObjectHandle new_dict)
1153 1117 {
1154 1118 assertStream();
1155   - dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->replaceDict(new_dict);
  1119 + dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceDict(new_dict);
1156 1120 }
1157 1121  
1158 1122 PointerHolder<Buffer>
... ... @@ -1160,14 +1124,14 @@ QPDFObjectHandle::getStreamData(qpdf_stream_decode_level_e level)
1160 1124 {
1161 1125 assertStream();
1162 1126 return dynamic_cast<QPDF_Stream*>(
1163   - m->obj.getPointer())->getStreamData(level);
  1127 + obj.getPointer())->getStreamData(level);
1164 1128 }
1165 1129  
1166 1130 PointerHolder<Buffer>
1167 1131 QPDFObjectHandle::getRawStreamData()
1168 1132 {
1169 1133 assertStream();
1170   - return dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->getRawStreamData();
  1134 + return dynamic_cast<QPDF_Stream*>(obj.getPointer())->getRawStreamData();
1171 1135 }
1172 1136  
1173 1137 bool
... ... @@ -1177,7 +1141,7 @@ QPDFObjectHandle::pipeStreamData(Pipeline* p,
1177 1141 bool suppress_warnings, bool will_retry)
1178 1142 {
1179 1143 assertStream();
1180   - return dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->pipeStreamData(
  1144 + return dynamic_cast<QPDF_Stream*>(obj.getPointer())->pipeStreamData(
1181 1145 p, encode_flags, decode_level, suppress_warnings, will_retry);
1182 1146 }
1183 1147  
... ... @@ -1208,7 +1172,7 @@ QPDFObjectHandle::replaceStreamData(PointerHolder&lt;Buffer&gt; data,
1208 1172 QPDFObjectHandle const& decode_parms)
1209 1173 {
1210 1174 assertStream();
1211   - dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->replaceStreamData(
  1175 + dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
1212 1176 data, filter, decode_parms);
1213 1177 }
1214 1178  
... ... @@ -1221,7 +1185,7 @@ QPDFObjectHandle::replaceStreamData(std::string const&amp; data,
1221 1185 PointerHolder<Buffer> b = new Buffer(data.length());
1222 1186 unsigned char* bp = b->getBuffer();
1223 1187 memcpy(bp, data.c_str(), data.length());
1224   - dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->replaceStreamData(
  1188 + dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
1225 1189 b, filter, decode_parms);
1226 1190 }
1227 1191  
... ... @@ -1231,26 +1195,26 @@ QPDFObjectHandle::replaceStreamData(PointerHolder&lt;StreamDataProvider&gt; provider,
1231 1195 QPDFObjectHandle const& decode_parms)
1232 1196 {
1233 1197 assertStream();
1234   - dynamic_cast<QPDF_Stream*>(m->obj.getPointer())->replaceStreamData(
  1198 + dynamic_cast<QPDF_Stream*>(obj.getPointer())->replaceStreamData(
1235 1199 provider, filter, decode_parms);
1236 1200 }
1237 1201  
1238 1202 QPDFObjGen
1239 1203 QPDFObjectHandle::getObjGen() const
1240 1204 {
1241   - return QPDFObjGen(this->m->objid, this->m->generation);
  1205 + return QPDFObjGen(this->objid, this->generation);
1242 1206 }
1243 1207  
1244 1208 int
1245 1209 QPDFObjectHandle::getObjectID() const
1246 1210 {
1247   - return this->m->objid;
  1211 + return this->objid;
1248 1212 }
1249 1213  
1250 1214 int
1251 1215 QPDFObjectHandle::getGeneration() const
1252 1216 {
1253   - return this->m->generation;
  1217 + return this->generation;
1254 1218 }
1255 1219  
1256 1220 std::map<std::string, QPDFObjectHandle>
... ... @@ -1352,8 +1316,8 @@ std::vector&lt;QPDFObjectHandle&gt;
1352 1316 QPDFObjectHandle::getPageContents()
1353 1317 {
1354 1318 std::string description = "page object " +
1355   - QUtil::int_to_string(this->m->objid) + " " +
1356   - QUtil::int_to_string(this->m->generation);
  1319 + QUtil::int_to_string(this->objid) + " " +
  1320 + QUtil::int_to_string(this->generation);
1357 1321 std::string all_description;
1358 1322 return this->getKey("/Contents").arrayOrStreamToStreamArray(
1359 1323 description, all_description);
... ... @@ -1480,8 +1444,8 @@ QPDFObjectHandle::unparse()
1480 1444 std::string result;
1481 1445 if (this->isIndirect())
1482 1446 {
1483   - result = QUtil::int_to_string(this->m->objid) + " " +
1484   - QUtil::int_to_string(this->m->generation) + " R";
  1447 + result = QUtil::int_to_string(this->objid) + " " +
  1448 + QUtil::int_to_string(this->generation) + " R";
1485 1449 }
1486 1450 else
1487 1451 {
... ... @@ -1493,13 +1457,13 @@ QPDFObjectHandle::unparse()
1493 1457 std::string
1494 1458 QPDFObjectHandle::unparseResolved()
1495 1459 {
1496   - if (this->m->reserved)
  1460 + if (this->reserved)
1497 1461 {
1498 1462 throw std::logic_error(
1499 1463 "QPDFObjectHandle: attempting to unparse a reserved object");
1500 1464 }
1501 1465 dereference();
1502   - return this->m->obj->unparse();
  1466 + return this->obj->unparse();
1503 1467 }
1504 1468  
1505 1469 std::string
... ... @@ -1508,7 +1472,7 @@ QPDFObjectHandle::unparseBinary()
1508 1472 if (this->isString())
1509 1473 {
1510 1474 return dynamic_cast<QPDF_String*>(
1511   - this->m->obj.getPointer())->unparse(true);
  1475 + this->obj.getPointer())->unparse(true);
1512 1476 }
1513 1477 else
1514 1478 {
... ... @@ -1525,13 +1489,13 @@ QPDFObjectHandle::getJSON(bool dereference_indirect)
1525 1489 }
1526 1490 else
1527 1491 {
1528   - if (this->m->reserved)
  1492 + if (this->reserved)
1529 1493 {
1530 1494 throw std::logic_error(
1531 1495 "QPDFObjectHandle: attempting to unparse a reserved object");
1532 1496 }
1533 1497 dereference();
1534   - return this->m->obj->getJSON();
  1498 + return this->obj->getJSON();
1535 1499 }
1536 1500 }
1537 1501  
... ... @@ -1577,8 +1541,8 @@ void
1577 1541 QPDFObjectHandle::pipePageContents(Pipeline* p)
1578 1542 {
1579 1543 std::string description = "page object " +
1580   - QUtil::int_to_string(this->m->objid) + " " +
1581   - QUtil::int_to_string(this->m->generation);
  1544 + QUtil::int_to_string(this->objid) + " " +
  1545 + QUtil::int_to_string(this->generation);
1582 1546 std::string all_description;
1583 1547 this->getKey("/Contents").pipeContentStreams(
1584 1548 p, description, all_description);
... ... @@ -1613,8 +1577,8 @@ void
1613 1577 QPDFObjectHandle::parsePageContents(ParserCallbacks* callbacks)
1614 1578 {
1615 1579 std::string description = "page object " +
1616   - QUtil::int_to_string(this->m->objid) + " " +
1617   - QUtil::int_to_string(this->m->generation);
  1580 + QUtil::int_to_string(this->objid) + " " +
  1581 + QUtil::int_to_string(this->generation);
1618 1582 this->getKey("/Contents").parseContentStream_internal(
1619 1583 description, callbacks);
1620 1584 }
... ... @@ -1623,8 +1587,8 @@ void
1623 1587 QPDFObjectHandle::filterPageContents(TokenFilter* filter, Pipeline* next)
1624 1588 {
1625 1589 std::string description = "token filter for page object " +
1626   - QUtil::int_to_string(this->m->objid) + " " +
1627   - QUtil::int_to_string(this->m->generation);
  1590 + QUtil::int_to_string(this->objid) + " " +
  1591 + QUtil::int_to_string(this->generation);
1628 1592 Pl_QPDFTokenizer token_pipeline(description.c_str(), filter, next);
1629 1593 this->pipePageContents(&token_pipeline);
1630 1594 }
... ... @@ -1633,8 +1597,8 @@ void
1633 1597 QPDFObjectHandle::filterAsContents(TokenFilter* filter, Pipeline* next)
1634 1598 {
1635 1599 std::string description = "token filter for object " +
1636   - QUtil::int_to_string(this->m->objid) + " " +
1637   - QUtil::int_to_string(this->m->generation);
  1600 + QUtil::int_to_string(this->objid) + " " +
  1601 + QUtil::int_to_string(this->generation);
1638 1602 Pl_QPDFTokenizer token_pipeline(description.c_str(), filter, next);
1639 1603 this->pipeStreamData(&token_pipeline, 0, qpdf_dl_specialized);
1640 1604 }
... ... @@ -1745,7 +1709,7 @@ QPDFObjectHandle::addTokenFilter(PointerHolder&lt;TokenFilter&gt; filter)
1745 1709 {
1746 1710 assertStream();
1747 1711 return dynamic_cast<QPDF_Stream*>(
1748   - m->obj.getPointer())->addTokenFilter(filter);
  1712 + obj.getPointer())->addTokenFilter(filter);
1749 1713 }
1750 1714  
1751 1715 QPDFObjectHandle
... ... @@ -2258,15 +2222,15 @@ qpdf_offset_t
2258 2222 QPDFObjectHandle::getParsedOffset()
2259 2223 {
2260 2224 dereference();
2261   - return this->m->obj->getParsedOffset();
  2225 + return this->obj->getParsedOffset();
2262 2226 }
2263 2227  
2264 2228 void
2265 2229 QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset)
2266 2230 {
2267   - if (this->m->obj.getPointer())
  2231 + if (this->obj.getPointer())
2268 2232 {
2269   - this->m->obj->setParsedOffset(offset);
  2233 + this->obj->setParsedOffset(offset);
2270 2234 }
2271 2235 }
2272 2236  
... ... @@ -2438,7 +2402,7 @@ QPDFObjectHandle::newStream(QPDF* qpdf)
2438 2402 new QPDF_Stream(qpdf, 0, 0, stream_dict, 0, 0)));
2439 2403 result.dereference();
2440 2404 QPDF_Stream* stream =
2441   - dynamic_cast<QPDF_Stream*>(result.m->obj.getPointer());
  2405 + dynamic_cast<QPDF_Stream*>(result.obj.getPointer());
2442 2406 stream->setObjGen(result.getObjectID(), result.getGeneration());
2443 2407 return result;
2444 2408 }
... ... @@ -2469,8 +2433,8 @@ QPDFObjectHandle::newReserved(QPDF* qpdf)
2469 2433 QPDFObjectHandle reserved = qpdf->makeIndirectObject(
2470 2434 QPDFObjectHandle(new QPDF_Reserved()));
2471 2435 QPDFObjectHandle result =
2472   - newIndirect(qpdf, reserved.m->objid, reserved.m->generation);
2473   - result.m->reserved = true;
  2436 + newIndirect(qpdf, reserved.objid, reserved.generation);
  2437 + result.reserved = true;
2474 2438 return result;
2475 2439 }
2476 2440  
... ... @@ -2478,18 +2442,18 @@ void
2478 2442 QPDFObjectHandle::setObjectDescription(QPDF* owning_qpdf,
2479 2443 std::string const& object_description)
2480 2444 {
2481   - if (isInitialized() && this->m->obj.getPointer())
  2445 + if (isInitialized() && this->obj.getPointer())
2482 2446 {
2483   - this->m->obj->setDescription(owning_qpdf, object_description);
  2447 + this->obj->setDescription(owning_qpdf, object_description);
2484 2448 }
2485 2449 }
2486 2450  
2487 2451 bool
2488 2452 QPDFObjectHandle::hasObjectDescription()
2489 2453 {
2490   - if (isInitialized() && this->m->obj.getPointer())
  2454 + if (isInitialized() && this->obj.getPointer())
2491 2455 {
2492   - return this->m->obj->hasDescription();
  2456 + return this->obj->hasDescription();
2493 2457 }
2494 2458 return false;
2495 2459 }
... ... @@ -2511,7 +2475,7 @@ QPDFObjectHandle::shallowCopy()
2511 2475 {
2512 2476 QTC::TC("qpdf", "QPDFObjectHandle shallow copy array");
2513 2477 // No newArray for shallow copying the sparse array
2514   - QPDF_Array* arr = dynamic_cast<QPDF_Array*>(m->obj.getPointer());
  2478 + QPDF_Array* arr = dynamic_cast<QPDF_Array*>(obj.getPointer());
2515 2479 new_obj = QPDFObjectHandle(
2516 2480 new QPDF_Array(arr->getElementsForShallowCopy()));
2517 2481 }
... ... @@ -2544,7 +2508,7 @@ QPDFObjectHandle::copyObject(std::set&lt;QPDFObjGen&gt;&amp; visited,
2544 2508 "attempt to make a stream into a direct object");
2545 2509 }
2546 2510  
2547   - QPDFObjGen cur_og(this->m->objid, this->m->generation);
  2511 + QPDFObjGen cur_og(this->objid, this->generation);
2548 2512 if (cur_og.getObj() != 0)
2549 2513 {
2550 2514 if (visited.count(cur_og))
... ... @@ -2565,9 +2529,9 @@ QPDFObjectHandle::copyObject(std::set&lt;QPDFObjGen&gt;&amp; visited,
2565 2529 }
2566 2530  
2567 2531 dereference();
2568   - this->m->qpdf = 0;
2569   - this->m->objid = 0;
2570   - this->m->generation = 0;
  2532 + this->qpdf = 0;
  2533 + this->objid = 0;
  2534 + this->generation = 0;
2571 2535  
2572 2536 PointerHolder<QPDFObject> new_obj;
2573 2537  
... ... @@ -2638,7 +2602,7 @@ QPDFObjectHandle::copyObject(std::set&lt;QPDFObjGen&gt;&amp; visited,
2638 2602 "unknown object type");
2639 2603 }
2640 2604  
2641   - this->m->obj = new_obj;
  2605 + this->obj = new_obj;
2642 2606  
2643 2607 if (cur_og.getObj())
2644 2608 {
... ... @@ -2656,7 +2620,7 @@ QPDFObjectHandle::makeDirect()
2656 2620 void
2657 2621 QPDFObjectHandle::assertInitialized() const
2658 2622 {
2659   - if (! this->m->initialized)
  2623 + if (! this->initialized)
2660 2624 {
2661 2625 throw std::logic_error("operation attempted on uninitialized "
2662 2626 "QPDFObjectHandle");
... ... @@ -2669,7 +2633,7 @@ QPDFObjectHandle::typeWarning(char const* expected_type,
2669 2633 {
2670 2634 QPDF* context = 0;
2671 2635 std::string description;
2672   - if (this->m->obj->getDescription(context, description))
  2636 + if (this->obj->getDescription(context, description))
2673 2637 {
2674 2638 warn(context,
2675 2639 QPDFExc(
... ... @@ -2691,7 +2655,7 @@ QPDFObjectHandle::warnIfPossible(std::string const&amp; warning,
2691 2655 {
2692 2656 QPDF* context = 0;
2693 2657 std::string description;
2694   - if (this->m->obj->getDescription(context, description))
  2658 + if (this->obj->getDescription(context, description))
2695 2659 {
2696 2660 warn(context,
2697 2661 QPDFExc(
... ... @@ -2863,15 +2827,15 @@ QPDFObjectHandle::assertPageObject()
2863 2827 void
2864 2828 QPDFObjectHandle::dereference()
2865 2829 {
2866   - if (this->m->obj.getPointer() == 0)
  2830 + if (this->obj.getPointer() == 0)
2867 2831 {
2868 2832 PointerHolder<QPDFObject> obj = QPDF::Resolver::resolve(
2869   - this->m->qpdf, this->m->objid, this->m->generation);
  2833 + this->qpdf, this->objid, this->generation);
2870 2834 if (obj.getPointer() == 0)
2871 2835 {
2872 2836 // QPDF::resolve never returns an uninitialized object, but
2873 2837 // check just in case.
2874   - this->m->obj = new QPDF_Null();
  2838 + this->obj = new QPDF_Null();
2875 2839 }
2876 2840 else if (dynamic_cast<QPDF_Reserved*>(obj.getPointer()))
2877 2841 {
... ... @@ -2879,8 +2843,8 @@ QPDFObjectHandle::dereference()
2879 2843 }
2880 2844 else
2881 2845 {
2882   - this->m->reserved = false;
2883   - this->m->obj = obj;
  2846 + this->reserved = false;
  2847 + this->obj = obj;
2884 2848 }
2885 2849 }
2886 2850 }
... ...