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