fix 90452 threading by subject slow when threads are very large, sr=mscott, a=bsmedberg

This commit is contained in:
bienvenu%nventure.com 2005-07-28 14:21:11 +00:00
Родитель d8d22d4dfd
Коммит 279b803590
1 изменённых файлов: 51 добавлений и 37 удалений

Просмотреть файл

@ -290,6 +290,19 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr *child, nsIMsgDBHdr *inReplyTo,
PRBool hdrMoved = PR_FALSE;
nsCOMPtr <nsIMsgDBHdr> curHdr;
// This is an ugly but simple fix for a difficult problem. Basically, when we add
// a message to a thread, we have to run through the thread to see if the new
// message is a parent of an existing message in the thread, and adjust things
// accordingly. If you thread by subject, and you have a large folder with
// messages w/ all the same subject, this code can take a really long time. So the
// pragmatic thing is to say that for threads with more than 1000 messages, it's
// simply not worth dealing with the case where the parent comes in after the
// child. Threads with more than 1000 messages are pretty unwieldy anyway.
// See Bug 90452
if (numChildren < 1000)
{
for (childIndex = 0; childIndex < numChildren; childIndex++)
{
nsMsgKey msgKey;
@ -334,10 +347,11 @@ NS_IMETHODIMP nsMsgThread::AddChild(nsIMsgDBHdr *child, nsIMsgDBHdr *inReplyTo,
// OK, this is a reparenting - need to send notification
if (announcer)
announcer->NotifyParentChangedAll(msgKey, oldThreadParent, newHdrKey, nsnull);
#ifdef DEBUG_bienvenu1
#ifdef DEBUG_bienvenu1
if (newHdrKey != m_threadKey)
printf("adding second level child\n");
#endif
#endif
}
}
}
}