Permalink
Browse files

Avoid traversing same object twice when copying objects

This is a performance fix.  The output is unchanged.

Fixes #28.
  • Loading branch information...
1 parent 0b61275 commit c9a9fe9c2f8837bdfdd2b0e58fce9a82b0a64881 @jberkenbilt jberkenbilt committed Dec 26, 2013
Showing with 14 additions and 0 deletions.
  1. +8 −0 ChangeLog
  2. +5 −0 libqpdf/QPDF.cc
  3. +1 −0 qpdf/qpdf.testcov
View
@@ -1,3 +1,11 @@
+2013-12-26 Jay Berkenbilt <ejb@ql.org>
+
+ * Bug fix: when copying foreign objects (which occurs during page
+ splitting among other cases), avoid traversing the same object
+ more than once if it appears more than once in the same direct
+ object. This bug is performance-only and does not affect the
+ actual output.
+
2013-12-17 Jay Berkenbilt <ejb@ql.org>
* 5.1.0: release
View
@@ -1755,6 +1755,11 @@ QPDF::reserveObjects(QPDFObjectHandle foreign, ObjCopier& obj_copier,
QTC::TC("qpdf", "QPDF loop reserving objects");
return;
}
+ if (obj_copier.object_map.find(foreign_og) != obj_copier.object_map.end())
+ {
+ QTC::TC("qpdf", "QPDF already reserved object");
+ return;
+ }
QTC::TC("qpdf", "QPDF copy indirect");
obj_copier.visiting.insert(foreign_og);
std::map<QPDFObjGen, QPDFObjectHandle>::iterator mapping =
View
@@ -268,3 +268,4 @@ QPDF xref space 2
qpdf pages range omitted at end 0
qpdf pages range omitted in middle 0
qpdf npages 0
+QPDF already reserved object 0

0 comments on commit c9a9fe9

Please sign in to comment.