зеркало из https://github.com/mozilla/gecko-dev.git
139576 r=bienvenu sr=mscott Fixing a performance regression in downloading pop3 mail on MAC and other platforms (not win32 & linux). This was because seek is expensive, atleast on mac. Made it so that we
seek whenever absolutely necessary.
This commit is contained in:
Родитель
b3a9cf3cb4
Коммит
247ce996c4
|
@ -70,6 +70,7 @@ nsMailDatabase::~nsMailDatabase()
|
|||
|
||||
NS_IMETHODIMP nsMailDatabase::SetFolderStream(nsIOFileStream *aFileStream)
|
||||
{
|
||||
NS_ASSERTION(!m_folderStream || !aFileStream, "m_folderStream is not null and we are assigning a non null stream to it");
|
||||
m_folderStream = aFileStream; //m_folderStream is set externally, so m_ownFolderStream is false
|
||||
m_ownFolderStream = PR_FALSE;
|
||||
return NS_OK;
|
||||
|
@ -331,6 +332,7 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
|||
MsgFlags flag, nsIOFileStream **ppFileStream)
|
||||
{
|
||||
static char buf[50];
|
||||
PRInt32 folderStreamPos; //saves the folderStream pos in case we are sharing the stream with other code
|
||||
nsIOFileStream *fileStream = (m_folderStream) ? m_folderStream : *ppFileStream;
|
||||
//#ifdef GET_FILE_STUFF_TOGETHER
|
||||
#ifdef XP_MAC
|
||||
|
@ -356,6 +358,11 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
|||
{
|
||||
fileStream = new nsIOFileStream(nsFileSpec(*m_folderSpec));
|
||||
}
|
||||
else if (!m_ownFolderStream)
|
||||
{
|
||||
m_folderStream->flush();
|
||||
folderStreamPos = m_folderStream->tell();
|
||||
}
|
||||
if (fileStream)
|
||||
{
|
||||
PRUint32 msgOffset;
|
||||
|
@ -454,6 +461,8 @@ void nsMailDatabase::UpdateFolderFlag(nsIMsgDBHdr *mailHdr, PRBool bSet,
|
|||
//#endif // GET_FILE_STUFF_TOGETHER
|
||||
if (!m_folderStream)
|
||||
*ppFileStream = fileStream; // This tells the caller that we opened the file, and please to close it.
|
||||
else if (!m_ownFolderStream)
|
||||
m_folderStream->seek(PR_SEEK_SET, folderStreamPos);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsMailDatabase::GetSummaryValid(PRBool *aResult)
|
||||
|
|
|
@ -447,11 +447,9 @@ nsresult nsPop3Sink::WriteLineToMailbox(char *buffer)
|
|||
// See bug 62480
|
||||
if (!m_outFileStream)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
|
||||
NS_ASSERTION(m_outFileStream->eof(), "we are not writing to end-of-file");
|
||||
|
||||
/*This file stream is also used by db so file pos could have changed
|
||||
set it to the end of the file before writing anything */
|
||||
|
||||
m_outFileStream->seek(PR_SEEK_END, 0);
|
||||
PRInt32 bytes = m_outFileStream->write(buffer,bufferLen);
|
||||
if (bytes != bufferLen) return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
@ -475,13 +473,8 @@ nsPop3Sink::IncorporateComplete(nsIMsgWindow *msgWindow)
|
|||
if (NS_FAILED(rv)) return rv;
|
||||
NS_ASSERTION(m_newMailParser, "could not get m_newMailParser");
|
||||
if (m_newMailParser)
|
||||
{
|
||||
m_newMailParser->PublishMsgHeader(msgWindow);
|
||||
|
||||
//PublishMsgHeader might have changed the postion of file stream pointer, reset it back.
|
||||
m_outFileStream->seek(PR_SEEK_END, 0);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("Incorporate message complete.\n");
|
||||
#endif
|
||||
|
|
Загрузка…
Ссылка в новой задаче