Fixed estimation of generated size when no re-encoding is needed.

This commit is contained in:
Vincent Richard 2015-05-08 09:16:01 +02:00
parent e071de8a60
commit 9df44078b8

View File

@ -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()));
}
}
}