diff options
author | Vincent Richard <[email protected]> | 2015-05-08 07:16:01 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2015-05-08 07:16:01 +0000 |
commit | 9df44078b87785f114689fc0b12e084aba903df0 (patch) | |
tree | 151d7a299a8ae5720dc6f2f6cd3f25588cab9f42 | |
parent | Fixed issue #110: wrong number of bytes returned. (diff) | |
download | vmime-9df44078b87785f114689fc0b12e084aba903df0.tar.gz vmime-9df44078b87785f114689fc0b12e084aba903df0.zip |
Fixed estimation of generated size when no re-encoding is needed.
-rw-r--r-- | src/vmime/body.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/vmime/body.cpp b/src/vmime/body.cpp index 8f5401cf..8b334352 100644 --- a/src/vmime/body.cpp +++ b/src/vmime/body.cpp @@ -544,10 +544,18 @@ size_t body::getGeneratedSize(const generationContext& ctx) // Simple body else { - shared_ptr <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder(); - shared_ptr <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder(); + if (getEncoding() == m_contents->getEncoding()) + { + // No re-encoding has to be performed + return m_contents->getLength(); + } + else + { + shared_ptr <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder(); + shared_ptr <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder(); - return dstEncoder->getEncodedSize(srcEncoder->getDecodedSize(m_contents->getLength())); + return dstEncoder->getEncodedSize(srcEncoder->getDecodedSize(m_contents->getLength())); + } } } |