Commit 23d50a2f14db56be4cb4efcc413b8ef44713613f

Authored by m-holger
1 parent c7005e8a

Remove QPDFObjectHandle::initialized

include/qpdf/QPDFObjectHandle.hh
@@ -1584,7 +1584,6 @@ class QPDFObjectHandle @@ -1584,7 +1584,6 @@ class QPDFObjectHandle
1584 QPDF* qpdf, 1584 QPDF* qpdf,
1585 QPDFObjGen const& og, 1585 QPDFObjGen const& og,
1586 std::shared_ptr<QPDFObject> const& obj) : 1586 std::shared_ptr<QPDFObject> const& obj) :
1587 - initialized(true),  
1588 qpdf(qpdf), 1587 qpdf(qpdf),
1589 og(og), 1588 og(og),
1590 obj(obj) 1589 obj(obj)
@@ -1640,8 +1639,6 @@ class QPDFObjectHandle @@ -1640,8 +1639,6 @@ class QPDFObjectHandle
1640 static void warn(QPDF*, QPDFExc const&); 1639 static void warn(QPDF*, QPDFExc const&);
1641 void checkOwnership(QPDFObjectHandle const&) const; 1640 void checkOwnership(QPDFObjectHandle const&) const;
1642 1641
1643 - bool initialized;  
1644 -  
1645 // Moving members of QPDFObjectHandle into a smart pointer incurs 1642 // Moving members of QPDFObjectHandle into a smart pointer incurs
1646 // a substantial performance penalty since QPDFObjectHandle 1643 // a substantial performance penalty since QPDFObjectHandle
1647 // objects are copied around so frequently. 1644 // objects are copied around so frequently.
@@ -1888,13 +1885,13 @@ QPDFObjectHandle::getGeneration() const @@ -1888,13 +1885,13 @@ QPDFObjectHandle::getGeneration() const
1888 inline bool 1885 inline bool
1889 QPDFObjectHandle::isIndirect() const 1886 QPDFObjectHandle::isIndirect() const
1890 { 1887 {
1891 - return initialized && (getObjectID() != 0); 1888 + return (obj != nullptr) && (getObjectID() != 0);
1892 } 1889 }
1893 1890
1894 inline bool 1891 inline bool
1895 QPDFObjectHandle::isInitialized() const 1892 QPDFObjectHandle::isInitialized() const
1896 { 1893 {
1897 - return initialized; 1894 + return obj != nullptr;
1898 } 1895 }
1899 1896
1900 // Indirect object accessors 1897 // Indirect object accessors
@@ -1915,7 +1912,7 @@ QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset) @@ -1915,7 +1912,7 @@ QPDFObjectHandle::setParsedOffset(qpdf_offset_t offset)
1915 { 1912 {
1916 // This is called during parsing on newly created direct objects, 1913 // This is called during parsing on newly created direct objects,
1917 // so we can't call dereference() here. 1914 // so we can't call dereference() here.
1918 - if (initialized) { 1915 + if (isInitialized()) {
1919 this->obj->setParsedOffset(offset); 1916 this->obj->setParsedOffset(offset);
1920 } 1917 }
1921 } 1918 }
libqpdf/QPDFObjectHandle.cc
@@ -236,13 +236,11 @@ LastChar::getLastChar() @@ -236,13 +236,11 @@ LastChar::getLastChar()
236 } 236 }
237 237
238 QPDFObjectHandle::QPDFObjectHandle() : 238 QPDFObjectHandle::QPDFObjectHandle() :
239 - initialized(false),  
240 qpdf(nullptr) 239 qpdf(nullptr)
241 { 240 {
242 } 241 }
243 242
244 QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) : 243 QPDFObjectHandle::QPDFObjectHandle(std::shared_ptr<QPDFObject> const& data) :
245 - initialized(true),  
246 qpdf(nullptr), 244 qpdf(nullptr),
247 obj(data) 245 obj(data)
248 { 246 {
@@ -369,7 +367,7 @@ QPDFObjectHandle::isDirectNull() const @@ -369,7 +367,7 @@ QPDFObjectHandle::isDirectNull() const
369 // Don't call dereference() -- this is a const method, and we know 367 // Don't call dereference() -- this is a const method, and we know
370 // objid == 0, so there's nothing to resolve. 368 // objid == 0, so there's nothing to resolve.
371 return ( 369 return (
372 - initialized && (getObjectID() == 0) && 370 + isInitialized() && (getObjectID() == 0) &&
373 (obj->getTypeCode() == QPDFObject::ot_null)); 371 (obj->getTypeCode() == QPDFObject::ot_null));
374 } 372 }
375 373
@@ -2373,7 +2371,7 @@ QPDFObjectHandle::makeDirect(bool allow_streams) @@ -2373,7 +2371,7 @@ QPDFObjectHandle::makeDirect(bool allow_streams)
2373 void 2371 void
2374 QPDFObjectHandle::assertInitialized() const 2372 QPDFObjectHandle::assertInitialized() const
2375 { 2373 {
2376 - if (!initialized) { 2374 + if (!isInitialized()) {
2377 throw std::logic_error("operation attempted on uninitialized " 2375 throw std::logic_error("operation attempted on uninitialized "
2378 "QPDFObjectHandle"); 2376 "QPDFObjectHandle");
2379 } 2377 }
@@ -2608,7 +2606,7 @@ QPDFObjectHandle::assertPageObject() @@ -2608,7 +2606,7 @@ QPDFObjectHandle::assertPageObject()
2608 bool 2606 bool
2609 QPDFObjectHandle::dereference() 2607 QPDFObjectHandle::dereference()
2610 { 2608 {
2611 - if (!this->initialized) { 2609 + if (!isInitialized()) {
2612 return false; 2610 return false;
2613 } 2611 }
2614 if (this->obj->getTypeCode() == QPDFObject::ot_unresolved) { 2612 if (this->obj->getTypeCode() == QPDFObject::ot_unresolved) {