Commit d8e078fbb775fb585b3c908b89139561d98c786c

Authored by m-holger
1 parent acd0acf1

Remove redundant loop in QPDFWriter::prepareFileForWrite

Showing 1 changed file with 15 additions and 19 deletions
libqpdf/QPDFWriter.cc
... ... @@ -2034,29 +2034,25 @@ QPDFWriter::getTrimmedTrailer()
2034 2034 return trailer;
2035 2035 }
2036 2036  
  2037 +// Make document extension level information direct as required by the spec.
2037 2038 void
2038 2039 QPDFWriter::prepareFileForWrite()
2039 2040 {
2040   - // Make document extension level information direct as required by the spec.
2041   -
2042 2041 m->pdf.fixDanglingReferences();
2043   - QPDFObjectHandle root = m->pdf.getRoot();
2044   - for (auto const& key: root.getKeys()) {
2045   - QPDFObjectHandle oh = root.getKey(key);
2046   - if ((key == "/Extensions") && (oh.isDictionary())) {
2047   - bool extensions_indirect = false;
2048   - if (oh.isIndirect()) {
2049   - QTC::TC("qpdf", "QPDFWriter make Extensions direct");
2050   - extensions_indirect = true;
2051   - oh = root.replaceKeyAndGetNew(key, oh.shallowCopy());
2052   - }
2053   - if (oh.hasKey("/ADBE")) {
2054   - QPDFObjectHandle adbe = oh.getKey("/ADBE");
2055   - if (adbe.isIndirect()) {
2056   - QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
2057   - adbe.makeDirect();
2058   - oh.replaceKey("/ADBE", adbe);
2059   - }
  2042 + auto root = m->pdf.getRoot();
  2043 + auto oh = root.getKey("/Extensions");
  2044 + if (oh.isDictionary()) {
  2045 + const bool extensions_indirect = oh.isIndirect();
  2046 + if (extensions_indirect) {
  2047 + QTC::TC("qpdf", "QPDFWriter make Extensions direct");
  2048 + oh = root.replaceKeyAndGetNew("/Extensions", oh.shallowCopy());
  2049 + }
  2050 + if (oh.hasKey("/ADBE")) {
  2051 + auto adbe = oh.getKey("/ADBE");
  2052 + if (adbe.isIndirect()) {
  2053 + QTC::TC("qpdf", "QPDFWriter make ADBE direct", extensions_indirect ? 0 : 1);
  2054 + adbe.makeDirect();
  2055 + oh.replaceKey("/ADBE", adbe);
2060 2056 }
2061 2057 }
2062 2058 }
... ...