Commit 70665cb381ab8e24d6713bc2a6899520d6097500

Authored by Jay Berkenbilt
1 parent 38afdcea

Internally use unsafeShallowCopy where we can

Showing 1 changed file with 6 additions and 4 deletions
libqpdf/QPDFWriter.cc
... ... @@ -1502,12 +1502,14 @@ QPDFWriter::unparseObject(QPDFObjectHandle object, int level,
1502 1502 else if (object.isDictionary())
1503 1503 {
1504 1504 // Make a shallow copy of this object so we can modify it
1505   - // safely without affecting the original. This code makes
  1505 + // safely without affecting the original. This code makes
1506 1506 // assumptions about things that are made true in
1507 1507 // prepareFileForWrite, such as that certain things are direct
1508 1508 // objects so that replacing them doesn't leave unreferenced
1509   - // objects in the output.
1510   - object = object.shallowCopy();
  1509 + // objects in the output. We can use unsafeShallowCopy here
  1510 + // because we are all we are doing is removing or replacing
  1511 + // top-level keys.
  1512 + object = object.unsafeShallowCopy();
1511 1513  
1512 1514 // Handle special cases for specific dictionaries.
1513 1515  
... ... @@ -2413,7 +2415,7 @@ QPDFWriter::getTrimmedTrailer()
2413 2415 // Remove keys from the trailer that necessarily have to be
2414 2416 // replaced when writing the file.
2415 2417  
2416   - QPDFObjectHandle trailer = this->m->pdf.getTrailer().shallowCopy();
  2418 + QPDFObjectHandle trailer = this->m->pdf.getTrailer().unsafeShallowCopy();
2417 2419  
2418 2420 // Remove encryption keys
2419 2421 trailer.removeKey("/ID");
... ...