nsresult rv=NS_OK; mResultHdr = nsnull; if (mThreadParentKey == nsMsgKey_None) { rv = mThread->GetRootHdr(&mChildIndex, getter_AddRefs(mResultHdr)); NS_ASSERTION(NS_SUCCEEDED(rv) && mResultHdr, "better be able to get root hdr"); mChildIndex = 0; } else if (!mDone) { PRUint32 numChildren; mThread->GetNumChildren(&numChildren);  while (mChildIndex < (PRInt32) numChildren) { rv  = mThread->GetChildHdrAt(mChildIndex++, getter_AddRefs(mResultHdr)); if (NS_SUCCEEDED(rv) && mResultHdr) { nsMsgKey parentKey; nsMsgKey curKey;  if (mFilter && mFilter(mResultHdr, mClosure) != NS_OK) { mResultHdr = nsnull; continue; }  mResultHdr->GetThreadParent(&parentKey); mResultHdr->GetMessageKey(&curKey);    if (parentKey == mThreadParentKey || ((parentKey == 0 || parentKey == nsMsgKey_None) && mThreadParentKey == mFirstMsgKey && curKey != mThreadParentKey)) break; mResultHdr = nsnull; } else NS_ASSERTION(PR_FALSE, "better be able to get child"); }
nsresult rv=NS_OK; mResultHdr = nsnull; if (mThreadParentKey == nsMsgKey_None) { rv = mThread->GetRootHdr(&mChildIndex, getter_AddRefs(mResultHdr)); NS_ASSERTION(NS_SUCCEEDED(rv) && mResultHdr, "better be able to get root hdr"); mChildIndex = 0; } else if (!mDone) { PRUint32 numChildren; mThread->GetNumChildren(&numChildren);  while (mChildIndex < (PRInt32) numChildren) { rv  = mThread->GetChildHdrAt(mChildIndex++, getter_AddRefs(mResultHdr)); if (NS_SUCCEEDED(rv) && mResultHdr) { nsMsgKey parentKey; nsMsgKey curKey;  if (mFilter && mFilter(mResultHdr, mClosure) != NS_OK) { mResultHdr = nsnull; continue; }  mResultHdr->GetThreadParent(&parentKey); mResultHdr->GetMessageKey(&curKey);    if (parentKey == mThreadParentKey || (parentKey == nsMsgKey_None && mThreadParentKey == mFirstMsgKey && curKey != mThreadParentKey)) break; mResultHdr = nsnull; } else NS_ASSERTION(PR_FALSE, "better be able to get child"); }
nsresult nsMsgThreadEnumerator::Prefetch(){	nsresult rv=NS_OK;          // XXX or should this default to an error?	mResultHdr = nsnull;	if (mThreadParentKey == nsMsgKey_None)	{		rv = mThread->GetRootHdr(&mChildIndex, getter_AddRefs(mResultHdr));		NS_ASSERTION(NS_SUCCEEDED(rv) && mResultHdr, "better be able to get root hdr");		mChildIndex = 0; // since root can be anywhere, set mChildIndex to 0.	}	else if (!mDone)	{		PRUint32 numChildren;		mThread->GetNumChildren(&numChildren);		while (mChildIndex < (PRInt32) numChildren)		{			rv  = mThread->GetChildHdrAt(mChildIndex++, getter_AddRefs(mResultHdr));			if (NS_SUCCEEDED(rv) && mResultHdr)			{				nsMsgKey parentKey;				nsMsgKey curKey;                if (mFilter && mFilter(mResultHdr, mClosure) != NS_OK) {				    mResultHdr = nsnull;                    continue;                }				mResultHdr->GetThreadParent(&parentKey);				mResultHdr->GetMessageKey(&curKey);				// if the parent is the same as the msg we're enumerating over,				// or the parentKey isn't set, and we're iterating over the top				// level message in the thread, then leave mResultHdr set to cur msg.				if (parentKey == mThreadParentKey || 						((parentKey == 0 || parentKey == nsMsgKey_None) 							&& mThreadParentKey == mFirstMsgKey && curKey != mThreadParentKey))					break;				mResultHdr = nsnull;			}			else				NS_ASSERTION(PR_FALSE, "better be able to get child");		}    if (!mResultHdr && mThreadParentKey == mFirstMsgKey && !mFoundChildren && numChildren > 1)    {      mThread->ReparentMsgsWithInvalidParent(numChildren, mThreadParentKey);    }	}	if (!mResultHdr) 	{        mDone = PR_TRUE;		return NS_ERROR_FAILURE;    }    if (NS_FAILED(rv)) 	{        mDone = PR_TRUE;        return rv;    }	else		mNeedToPrefetch = PR_FALSE;  mFoundChildren = PR_TRUE;#ifdef DEBUG_bienvenu1	nsMsgKey debugMsgKey;	mResultHdr->GetMessageKey(&debugMsgKey);	printf("next for %ld = %ld\n", mThreadParentKey, debugMsgKey);#endif    return rv;}