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
ClosedFileInputSource::before()
{
if (nullptr == this->m->fis.get()) {
if (nullptr == this->m->fis) {
this->m->fis =
std::make_shared<FileInputSource>(this->m->filename.c_str());
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
JSON::write(Pipeline* p, size_t depth) const
{
if (nullptr == this->m->value.get()) {
if (nullptr == this->m->value) {
*p << "null";
} else {
this->m->value->write(p, depth);
@ -1122,7 +1122,7 @@ JSONParser::handleToken()
break;
}
if ((item.get() == nullptr) == (delimiter == '\0')) {
if ((item == nullptr) == (delimiter == '\0')) {
throw std::logic_error(
"JSONParser::handleToken: logic error: exactly one of item"
" or delimiter must be set");

View File

@ -26,7 +26,7 @@ Pl_Buffer::~Pl_Buffer()
void
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);
}
size_t cur_size = this->m->data->getSize();

View File

@ -86,7 +86,7 @@ Pl_Flate::warn(char const* msg, int code)
void
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(
this->identifier +
": Pl_Flate: write() called after finish() called");

View File

@ -18,7 +18,7 @@ Pl_RC4::Pl_RC4(
void
Pl_RC4::write(unsigned char const* data, size_t len)
{
if (this->outbuf.get() == nullptr) {
if (this->outbuf == nullptr) {
throw std::logic_error(
this->identifier +
": 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();
if ((foreign_stream_qpdf->m->immediate_copy_from) &&
(stream_buffer.get() == nullptr)) {
(stream_buffer == nullptr)) {
// Pull the stream data into a buffer before attempting
// the copy operation. Do it on the source stream so that
// if the source stream is copied multiple times, we don't

View File

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

View File

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

View File

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

View File

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

View File

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