Commit d16308b3f5b111a23e0290e14b54fda4455265f0
Committed by
Jay Berkenbilt
1 parent
e8cdc462
Tune QPDFWriter::writeString etc methods
Use string_view parameters and call pipeline write methods directly.
Showing
2 changed files
with
15 additions
and
11 deletions
include/qpdf/QPDFWriter.hh
| ... | ... | @@ -36,6 +36,7 @@ |
| 36 | 36 | #include <set> |
| 37 | 37 | #include <stdio.h> |
| 38 | 38 | #include <string> |
| 39 | +#include <string_view> | |
| 39 | 40 | #include <vector> |
| 40 | 41 | |
| 41 | 42 | #include <qpdf/Constants.h> |
| ... | ... | @@ -553,10 +554,10 @@ class QPDFWriter |
| 553 | 554 | |
| 554 | 555 | unsigned int bytesNeeded(long long n); |
| 555 | 556 | void writeBinary(unsigned long long val, unsigned int bytes); |
| 556 | - void writeString(std::string const& str); | |
| 557 | + void writeString(std::string_view str); | |
| 557 | 558 | void writeBuffer(std::shared_ptr<Buffer>&); |
| 558 | - void writeStringQDF(std::string const& str); | |
| 559 | - void writeStringNoQDF(std::string const& str); | |
| 559 | + void writeStringQDF(std::string_view str); | |
| 560 | + void writeStringNoQDF(std::string_view str); | |
| 560 | 561 | void writePad(size_t nspaces); |
| 561 | 562 | void assignCompressedObjectNumbers(QPDFObjGen const& og); |
| 562 | 563 | void enqueueObject(QPDFObjectHandle object); | ... | ... |
libqpdf/QPDFWriter.cc
| ... | ... | @@ -982,9 +982,10 @@ QPDFWriter::writeBinary(unsigned long long val, unsigned int bytes) |
| 982 | 982 | } |
| 983 | 983 | |
| 984 | 984 | void |
| 985 | -QPDFWriter::writeString(std::string const& str) | |
| 985 | +QPDFWriter::writeString(std::string_view str) | |
| 986 | 986 | { |
| 987 | - this->m->pipeline->writeString(str); | |
| 987 | + m->pipeline->write( | |
| 988 | + reinterpret_cast<unsigned char const*>(str.data()), str.size()); | |
| 988 | 989 | } |
| 989 | 990 | |
| 990 | 991 | void |
| ... | ... | @@ -994,18 +995,20 @@ QPDFWriter::writeBuffer(std::shared_ptr<Buffer>& b) |
| 994 | 995 | } |
| 995 | 996 | |
| 996 | 997 | void |
| 997 | -QPDFWriter::writeStringQDF(std::string const& str) | |
| 998 | +QPDFWriter::writeStringQDF(std::string_view str) | |
| 998 | 999 | { |
| 999 | - if (this->m->qdf_mode) { | |
| 1000 | - writeString(str); | |
| 1000 | + if (m->qdf_mode) { | |
| 1001 | + m->pipeline->write( | |
| 1002 | + reinterpret_cast<unsigned char const*>(str.data()), str.size()); | |
| 1001 | 1003 | } |
| 1002 | 1004 | } |
| 1003 | 1005 | |
| 1004 | 1006 | void |
| 1005 | -QPDFWriter::writeStringNoQDF(std::string const& str) | |
| 1007 | +QPDFWriter::writeStringNoQDF(std::string_view str) | |
| 1006 | 1008 | { |
| 1007 | - if (!this->m->qdf_mode) { | |
| 1008 | - writeString(str); | |
| 1009 | + if (!m->qdf_mode) { | |
| 1010 | + m->pipeline->write( | |
| 1011 | + reinterpret_cast<unsigned char const*>(str.data()), str.size()); | |
| 1009 | 1012 | } |
| 1010 | 1013 | } |
| 1011 | 1014 | ... | ... |