From 10a70cb843d60d8cca275ab5cff8dc32cb8171c1 Mon Sep 17 00:00:00 2001 From: Hazim Gazov Date: Fri, 11 Jun 2010 22:23:05 +0000 Subject: [PATCH] reduced memory usage and useless copying, maintain a queue for message items while filter is being applied and push them to the main deque after filtering finishes --- indra/newview/llfloatermessagelog.cpp | 21 ++++++++++++++++----- indra/newview/llfloatermessagelog.h | 2 +- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/indra/newview/llfloatermessagelog.cpp b/indra/newview/llfloatermessagelog.cpp index 575ed1ffb..38d6f031b 100644 --- a/indra/newview/llfloatermessagelog.cpp +++ b/indra/newview/llfloatermessagelog.cpp @@ -415,9 +415,7 @@ LLMessageLogFilterApply::LLMessageLogFilterApply() mFinished(FALSE), mProgress(0) { - //make extra sure we don't invalidate any iterators and reserve a deque exclusively for our use - mFilterTempMessages = LLFloaterMessageLog::sMessageLogEntries; - mIter = mFilterTempMessages.begin(); + mIter = LLFloaterMessageLog::sMessageLogEntries.begin(); } void LLMessageLogFilterApply::cancel() { @@ -425,7 +423,7 @@ void LLMessageLogFilterApply::cancel() } BOOL LLMessageLogFilterApply::tick() { - std::deque::iterator end = mFilterTempMessages.end(); + std::deque::iterator end = LLFloaterMessageLog::sMessageLogEntries.end(); if(mIter == end || !LLFloaterMessageLog::sInstance) { mFinished = TRUE; @@ -448,6 +446,18 @@ BOOL LLMessageLogFilterApply::tick() if(LLFloaterMessageLog::sInstance->mMessageLogFilterApply == this) { LLFloaterMessageLog::sInstance->stopApplyingFilter(); + + //we're done messing with the deque, push all queued items to the main deque + std::deque::iterator queueIter = mQueuedMessages.begin(); + std::deque::iterator queueEnd = mQueuedMessages.end(); + + while(queueIter != queueEnd) + { + LLFloaterMessageLog::sInstance->conditionalLog(LLFloaterMessageLogItem((*queueIter))); + ++queueIter; + } + + mQueuedMessages.clear(); } } @@ -690,9 +700,10 @@ void LLFloaterMessageLog::setNetInfoMode(ENetInfoMode mode) // static void LLFloaterMessageLog::onLog(LLMessageLogEntry entry) { - sMessageLogEntries.push_back(entry); + //don't mess with the queue while a filter's being applied, or face invalid iterators if(!sBusyApplyingFilter) { + sMessageLogEntries.push_back(entry); conditionalLog(LLFloaterMessageLogItem(entry)); } } diff --git a/indra/newview/llfloatermessagelog.h b/indra/newview/llfloatermessagelog.h index 653b92b36..b87ffaa6f 100644 --- a/indra/newview/llfloatermessagelog.h +++ b/indra/newview/llfloatermessagelog.h @@ -46,7 +46,7 @@ public: S32 mProgress; BOOL mFinished; private: - std::deque mFilterTempMessages; + std::deque mQueuedMessages; std::deque::iterator mIter; }; class LLFloaterMessageLog : public LLFloater, public LLEventTimer