From 0c2cd2338ef77441e5b6b2a4cf1f5d6591c5f480 Mon Sep 17 00:00:00 2001 From: Kevin Smith <git@kismith.co.uk> Date: Mon, 5 Nov 2012 07:50:34 +0000 Subject: Don't store duplicate status Change-Id: I28731080f2e0b0223faa5da8489993be0fd69f6f diff --git a/Swift/Controllers/StatusCache.cpp b/Swift/Controllers/StatusCache.cpp index 0e8c34d..ce69440 100644 --- a/Swift/Controllers/StatusCache.cpp +++ b/Swift/Controllers/StatusCache.cpp @@ -42,9 +42,20 @@ std::vector<StatusCache::PreviousStatus> StatusCache::getMatches(const std::stri } void StatusCache::addRecent(const std::string& text, StatusShow::Type type) { - previousStatuses_.push_back(PreviousStatus(text, type)); + if (text.empty()) { + return; + } + for (std::list<PreviousStatus>::iterator i = previousStatuses_.begin(); i != previousStatuses_.end(); ) { + if ((*i).first == text && (*i).second == type) { + previousStatuses_.erase(i++); + } + else { + ++i; + } + } + previousStatuses_.push_front(PreviousStatus(text, type)); for (size_t i = previousStatuses_.size(); i > MAX_ENTRIES; i--) { - previousStatuses_.pop_front(); + previousStatuses_.pop_back(); } saveRecents(); } -- cgit v0.10.2-6-g49f6