Small optimizations.

This commit is contained in:
Felix Geyer 2013-03-26 23:53:34 +01:00
parent 57b0c17733
commit 1c7e8f6921
4 changed files with 12 additions and 11 deletions

View file

@ -362,21 +362,22 @@ void Entry::addHistoryItem(Entry* entry)
Q_EMIT modified(); Q_EMIT modified();
} }
void Entry::removeHistoryItems(QList<Entry*> historyEntries) void Entry::removeHistoryItems(const QList<Entry*>& historyEntries)
{ {
bool emitModified = historyEntries.count() > 0; if (historyEntries.isEmpty()) {
return;
}
Q_FOREACH (Entry* entry, historyEntries) { Q_FOREACH (Entry* entry, historyEntries) {
Q_ASSERT(!entry->parent()); Q_ASSERT(!entry->parent());
Q_ASSERT(entry->uuid() == uuid()); Q_ASSERT(entry->uuid() == uuid());
int numberOfRemovedEntries = m_history.removeAll(entry); Q_ASSERT(m_history.contains(entry));
Q_ASSERT(numberOfRemovedEntries > 0);
Q_UNUSED(numberOfRemovedEntries); m_history.removeOne(entry);
delete entry; delete entry;
} }
if (emitModified) { Q_EMIT modified();
Q_EMIT modified();
}
} }
void Entry::truncateHistory() void Entry::truncateHistory()

View file

@ -108,7 +108,7 @@ public:
QList<Entry*> historyItems(); QList<Entry*> historyItems();
const QList<Entry*>& historyItems() const; const QList<Entry*>& historyItems() const;
void addHistoryItem(Entry* entry); void addHistoryItem(Entry* entry);
void removeHistoryItems(QList<Entry*> historyEntries); void removeHistoryItems(const QList<Entry*>& historyEntries);
void truncateHistory(); void truncateHistory();
Entry* clone() const; Entry* clone() const;
QString resolvePlaceholders(const QString& str) const; QString resolvePlaceholders(const QString& str) const;

View file

@ -267,7 +267,7 @@ void Group::setLastTopVisibleEntry(Entry* entry)
set(m_lastTopVisibleEntry, entry); set(m_lastTopVisibleEntry, entry);
} }
void Group::setExpires(const bool& value) void Group::setExpires(bool value)
{ {
if (m_timeInfo.expires() != value) { if (m_timeInfo.expires() != value) {
m_timeInfo.setExpires(value); m_timeInfo.setExpires(value);

View file

@ -69,7 +69,7 @@ public:
void setAutoTypeEnabled(TriState enable); void setAutoTypeEnabled(TriState enable);
void setSearchingEnabled(TriState enable); void setSearchingEnabled(TriState enable);
void setLastTopVisibleEntry(Entry* entry); void setLastTopVisibleEntry(Entry* entry);
void setExpires(const bool& value); void setExpires(bool value);
void setExpiryTime(const QDateTime& dateTime); void setExpiryTime(const QDateTime& dateTime);
void setUpdateTimeinfo(bool value); void setUpdateTimeinfo(bool value);