2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-05-30 00:40:52 +00:00

Code tidy: remove redundant calls to smart_ptrs get() method

This commit is contained in:
m-holger 2022-08-07 10:33:25 +01:00
parent a9c0b02668
commit 7c6901bce5
11 changed files with 15 additions and 16 deletions

View File

@ -23,7 +23,7 @@ ClosedFileInputSource::~ClosedFileInputSource()
void void
ClosedFileInputSource::before() ClosedFileInputSource::before()
{ {
if (nullptr == this->m->fis.get()) { if (nullptr == this->m->fis) {
this->m->fis = this->m->fis =
std::make_shared<FileInputSource>(this->m->filename.c_str()); std::make_shared<FileInputSource>(this->m->filename.c_str());
this->m->fis->seek(this->m->offset, SEEK_SET); this->m->fis->seek(this->m->offset, SEEK_SET);

View File

@ -204,7 +204,7 @@ JSON::JSON_blob::write(Pipeline* p, size_t) const
void void
JSON::write(Pipeline* p, size_t depth) const JSON::write(Pipeline* p, size_t depth) const
{ {
if (nullptr == this->m->value.get()) { if (nullptr == this->m->value) {
*p << "null"; *p << "null";
} else { } else {
this->m->value->write(p, depth); this->m->value->write(p, depth);
@ -1122,7 +1122,7 @@ JSONParser::handleToken()
break; break;
} }
if ((item.get() == nullptr) == (delimiter == '\0')) { if ((item == nullptr) == (delimiter == '\0')) {
throw std::logic_error( throw std::logic_error(
"JSONParser::handleToken: logic error: exactly one of item" "JSONParser::handleToken: logic error: exactly one of item"
" or delimiter must be set"); " or delimiter must be set");

View File

@ -26,7 +26,7 @@ Pl_Buffer::~Pl_Buffer()
void void
Pl_Buffer::write(unsigned char const* buf, size_t len) Pl_Buffer::write(unsigned char const* buf, size_t len)
{ {
if (this->m->data.get() == nullptr) { if (this->m->data == nullptr) {
this->m->data = std::make_shared<Buffer>(len); this->m->data = std::make_shared<Buffer>(len);
} }
size_t cur_size = this->m->data->getSize(); size_t cur_size = this->m->data->getSize();

View File

@ -86,7 +86,7 @@ Pl_Flate::warn(char const* msg, int code)
void void
Pl_Flate::write(unsigned char const* data, size_t len) Pl_Flate::write(unsigned char const* data, size_t len)
{ {
if (this->m->outbuf.get() == nullptr) { if (this->m->outbuf == nullptr) {
throw std::logic_error( throw std::logic_error(
this->identifier + this->identifier +
": Pl_Flate: write() called after finish() called"); ": Pl_Flate: write() called after finish() called");

View File

@ -18,7 +18,7 @@ Pl_RC4::Pl_RC4(
void void
Pl_RC4::write(unsigned char const* data, size_t len) Pl_RC4::write(unsigned char const* data, size_t len)
{ {
if (this->outbuf.get() == nullptr) { if (this->outbuf == nullptr) {
throw std::logic_error( throw std::logic_error(
this->identifier + this->identifier +
": Pl_RC4: write() called after finish() called"); ": Pl_RC4: write() called after finish() called");

View File

@ -2457,7 +2457,7 @@ QPDF::copyStreamData(QPDFObjectHandle result, QPDFObjectHandle foreign)
} }
std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer(); std::shared_ptr<Buffer> stream_buffer = stream->getStreamDataBuffer();
if ((foreign_stream_qpdf->m->immediate_copy_from) && if ((foreign_stream_qpdf->m->immediate_copy_from) &&
(stream_buffer.get() == nullptr)) { (stream_buffer == nullptr)) {
// Pull the stream data into a buffer before attempting // Pull the stream data into a buffer before attempting
// the copy operation. Do it on the source stream so that // the copy operation. Do it on the source stream so that
// if the source stream is copied multiple times, we don't // if the source stream is copied multiple times, we don't

View File

@ -50,7 +50,7 @@ QPDFEmbeddedFileDocumentHelper::QPDFEmbeddedFileDocumentHelper(QPDF& qpdf) :
bool bool
QPDFEmbeddedFileDocumentHelper::hasEmbeddedFiles() const QPDFEmbeddedFileDocumentHelper::hasEmbeddedFiles() const
{ {
return (this->m->embedded_files.get() != nullptr); return (this->m->embedded_files != nullptr);
} }
void void

View File

@ -223,7 +223,7 @@ ImageOptimizer::evaluate(std::string const& description)
Pl_Discard d; Pl_Discard d;
Pl_Count c("count", &d); Pl_Count c("count", &d);
std::shared_ptr<Pipeline> p = makePipeline(description, &c); std::shared_ptr<Pipeline> p = makePipeline(description, &c);
if (p.get() == nullptr) { if (p == nullptr) {
// message issued by makePipeline // message issued by makePipeline
return false; return false;
} }
@ -252,7 +252,7 @@ void
ImageOptimizer::provideStreamData(QPDFObjGen const&, Pipeline* pipeline) ImageOptimizer::provideStreamData(QPDFObjGen const&, Pipeline* pipeline)
{ {
std::shared_ptr<Pipeline> p = makePipeline("", pipeline); std::shared_ptr<Pipeline> p = makePipeline("", pipeline);
if (p.get() == nullptr) { if (p == nullptr) {
// Should not be possible // Should not be possible
image.warnIfPossible("unable to create pipeline after previous" image.warnIfPossible("unable to create pipeline after previous"
" success; image data will be lost"); " success; image data will be lost");
@ -2243,8 +2243,7 @@ QPDFJob::handleUnderOverlay(QPDF& pdf)
{ {
validateUnderOverlay(pdf, &m->underlay); validateUnderOverlay(pdf, &m->underlay);
validateUnderOverlay(pdf, &m->overlay); validateUnderOverlay(pdf, &m->overlay);
if ((nullptr == m->underlay.pdf.get()) && if ((nullptr == m->underlay.pdf) && (nullptr == m->overlay.pdf)) {
(nullptr == m->overlay.pdf.get())) {
return; return;
} }
std::map<int, std::vector<int>> underlay_pagenos; std::map<int, std::vector<int>> underlay_pagenos;

View File

@ -3122,10 +3122,10 @@ QPDFObjectHandle::dereference()
QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) { QPDF::Resolver::objectChanged(this->qpdf, getObjGen(), this->obj)) {
this->obj = nullptr; this->obj = nullptr;
} }
if (this->obj.get() == nullptr) { if (this->obj == nullptr) {
std::shared_ptr<QPDFObject> obj = std::shared_ptr<QPDFObject> obj =
QPDF::Resolver::resolve(this->qpdf, getObjGen()); QPDF::Resolver::resolve(this->qpdf, getObjGen());
if (obj.get() == nullptr) { if (obj == nullptr) {
// QPDF::resolve never returns an uninitialized object, but // QPDF::resolve never returns an uninitialized object, but
// check just in case. // check just in case.
this->obj = QPDF_Null::create(); this->obj = QPDF_Null::create();

View File

@ -82,7 +82,7 @@ QPDFOutlineDocumentHelper::resolveNamedDest(QPDFObjectHandle name)
result = this->m->dest_dict.getKey(name.getName()); result = this->m->dest_dict.getKey(name.getName());
} }
} else if (name.isString()) { } else if (name.isString()) {
if (nullptr == this->m->names_dest.get()) { if (nullptr == this->m->names_dest) {
QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names"); QPDFObjectHandle names = this->qpdf.getRoot().getKey("/Names");
if (names.isDictionary()) { if (names.isDictionary()) {
QPDFObjectHandle dests = names.getKey("/Dests"); QPDFObjectHandle dests = names.getKey("/Dests");

View File

@ -16,7 +16,7 @@ QPDFPageLabelDocumentHelper::QPDFPageLabelDocumentHelper(QPDF& qpdf) :
bool bool
QPDFPageLabelDocumentHelper::hasPageLabels() QPDFPageLabelDocumentHelper::hasPageLabels()
{ {
return nullptr != this->m->labels.get(); return nullptr != this->m->labels;
} }
QPDFObjectHandle QPDFObjectHandle