Performance bugfixes

This commit is contained in:
Jakub Melka
2018-12-01 12:36:25 +01:00
parent 26a2a8deb5
commit bc8617751e
3 changed files with 50 additions and 6 deletions

View File

@ -147,6 +147,11 @@ void PDFString::setString(const QByteArray& string)
m_string = string;
}
void PDFString::optimize()
{
m_string.shrink_to_fit();
}
bool PDFArray::equals(const PDFObjectContent* other) const
{
Q_ASSERT(dynamic_cast<const PDFArray*>(other));
@ -159,6 +164,11 @@ void PDFArray::appendItem(PDFObject object)
m_objects.push_back(std::move(object));
}
void PDFArray::optimize()
{
m_objects.shrink_to_fit();
}
bool PDFDictionary::equals(const PDFObjectContent* other) const
{
Q_ASSERT(dynamic_cast<const PDFDictionary*>(other));
@ -194,6 +204,16 @@ const PDFObject& PDFDictionary::get(const char* key) const
}
}
void PDFDictionary::optimize()
{
m_dictionary.shrink_to_fit();
for (DictionaryEntry& entry : m_dictionary)
{
entry.first.shrink_to_fit();
}
}
std::vector<PDFDictionary::DictionaryEntry>::const_iterator PDFDictionary::find(const QByteArray& key) const
{
return std::find_if(m_dictionary.cbegin(), m_dictionary.cend(), [&key](const DictionaryEntry& entry) { return entry.first == key; });