diff --git a/src/format/KeePass2XmlReader.cpp b/src/format/KeePass2XmlReader.cpp index 95ca47796..7a963fa20 100644 --- a/src/format/KeePass2XmlReader.cpp +++ b/src/format/KeePass2XmlReader.cpp @@ -82,18 +82,21 @@ void KeePass2XmlReader::readDatabase(QIODevice* device, Database* db, KeePass2Ra QHash >::const_iterator i; for (i = m_binaryMap.constBegin(); i != m_binaryMap.constEnd(); ++i) { - QPair target = i.value(); + const QPair& target = i.value(); target.first->attachments()->set(target.second, m_binaryPool[i.key()]); } m_meta->setUpdateDatetime(true); - Q_FOREACH (Group* group, m_groups) { - group->setUpdateTimeinfo(true); + QHash::const_iterator iGroup; + for (iGroup = m_groups.constBegin(); iGroup != m_groups.constEnd(); ++iGroup) { + iGroup.value()->setUpdateTimeinfo(true); } - Q_FOREACH (Entry* entry, m_entries) { - entry->setUpdateTimeinfo(true); - Q_FOREACH(Entry* histEntry, entry->historyItems()) { + QHash::const_iterator iEntry; + for (iEntry = m_entries.constBegin(); iEntry != m_entries.constEnd(); ++iEntry) { + iEntry.value()->setUpdateTimeinfo(true); + + Q_FOREACH (Entry* histEntry, iEntry.value()->historyItems()) { histEntry->setUpdateTimeinfo(true); } } @@ -895,18 +898,17 @@ Group* KeePass2XmlReader::getGroup(const Uuid& uuid) return 0; } - Q_FOREACH (Group* group, m_groups) { - if (group->uuid() == uuid) { - return group; - } + if (m_groups.contains(uuid)) { + return m_groups.value(uuid); + } + else { + Group* group = new Group(); + group->setUpdateTimeinfo(false); + group->setUuid(uuid); + group->setParent(m_tmpParent); + m_groups.insert(uuid, group); + return group; } - - Group* group = new Group(); - group->setUpdateTimeinfo(false); - group->setUuid(uuid); - group->setParent(m_tmpParent); - m_groups << group; - return group; } Entry* KeePass2XmlReader::getEntry(const Uuid& uuid) @@ -915,18 +917,17 @@ Entry* KeePass2XmlReader::getEntry(const Uuid& uuid) return 0; } - Q_FOREACH (Entry* entry, m_entries) { - if (entry->uuid() == uuid) { - return entry; - } + if (m_entries.contains(uuid)) { + return m_entries.value(uuid); + } + else { + Entry* entry = new Entry(); + entry->setUpdateTimeinfo(false); + entry->setUuid(uuid); + entry->setGroup(m_tmpParent); + m_entries.insert(uuid, entry); + return entry; } - - Entry* entry = new Entry(); - entry->setUpdateTimeinfo(false); - entry->setUuid(uuid); - entry->setGroup(m_tmpParent); - m_entries << entry; - return entry; } void KeePass2XmlReader::raiseError(int internalNumber) diff --git a/src/format/KeePass2XmlReader.h b/src/format/KeePass2XmlReader.h index 4f7288b62..f8cd15864 100644 --- a/src/format/KeePass2XmlReader.h +++ b/src/format/KeePass2XmlReader.h @@ -87,8 +87,8 @@ private: Database* m_db; Metadata* m_meta; Group* m_tmpParent; - QList m_groups; - QList m_entries; + QHash m_groups; + QHash m_entries; QHash m_binaryPool; QHash > m_binaryMap; };