Bug 453766 - Checking mCopyState and copySucceeded in nsMsgLocalMailFolder::EndCopy is not needed because these values is checked at the beginning of the function.; r=bienvenu
authorHiroyuki Ikezoe <ikezoe@clear-code.com>
Tue, 26 Oct 2010 13:51:38 +0100
changeset 6595 e6c88bcb6d6c3ee229c94b03d11cb121e23d2aa4
parent 6594 a8f88c9cb2d49967cba4a495f00e096a32069d6e
child 6596 081b2f960f1b669b29e7fa1adb892b1202ea0bd2
push id5078
push userbugzilla@standard8.plus.com
push dateTue, 26 Oct 2010 12:54:14 +0000
treeherdercomm-central@d657b735d2bb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbienvenu
bugs453766
Bug 453766 - Checking mCopyState and copySucceeded in nsMsgLocalMailFolder::EndCopy is not needed because these values is checked at the beginning of the function.; r=bienvenu
mailnews/local/src/nsLocalMailFolder.cpp
--- a/mailnews/local/src/nsLocalMailFolder.cpp
+++ b/mailnews/local/src/nsLocalMailFolder.cpp
@@ -2533,25 +2533,25 @@ void nsMsgLocalMailFolder::CopyPropertie
     destHdr->SetStringProperty(property.get(), sourceString.get());
   }
 
   nsMsgLabelValue label = 0;
   srcHdr->GetLabel(&label);
   destHdr->SetLabel(label);
 }
 
-NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool copySucceeded)
+NS_IMETHODIMP nsMsgLocalMailFolder::EndCopy(PRBool aCopySucceeded)
 {
   if (!mCopyState)
     return NS_OK;
 
   // we are the destination folder for a move/copy
-  nsresult rv = copySucceeded ? NS_OK : NS_ERROR_FAILURE;
-
-  if (!copySucceeded || mCopyState->m_writeFailed)
+  nsresult rv = aCopySucceeded ? NS_OK : NS_ERROR_FAILURE;
+
+  if (!aCopySucceeded || mCopyState->m_writeFailed)
   {
     if (mCopyState->m_fileStream)
       mCopyState->m_fileStream->Close();
 
     nsCOMPtr <nsILocalFile> pathFile;
     rv = GetFilePath(getter_AddRefs(pathFile));
 
     if (NS_SUCCEEDED(rv) && pathFile && mCopyState->m_curDstKey != nsMsgKey_None)
@@ -2570,46 +2570,43 @@ NS_IMETHODIMP nsMsgLocalMailFolder::EndC
     return NS_OK;
   }
 
   PRBool multipleCopiesFinished = (mCopyState->m_curCopyIndex >= mCopyState->m_totalMsgCount);
 
   nsRefPtr<nsLocalMoveCopyMsgTxn> localUndoTxn = mCopyState->m_undoMsgTxn;
 
   nsCOMPtr <nsISeekableStream> seekableStream;
-  if (mCopyState)
+  NS_ASSERTION(mCopyState->m_leftOver == 0, "whoops, something wrong with previous copy");
+  mCopyState->m_leftOver = 0; // reset to 0.
+  // need to reset this in case we're move/copying multiple msgs.
+  mCopyState->m_fromLineSeen = PR_FALSE;
+
+  // flush the copied message. We need a close at the end to get the
+  // file size and time updated correctly.
+  if (mCopyState->m_fileStream)
   {
-    NS_ASSERTION(mCopyState->m_leftOver == 0, "whoops, something wrong with previous copy");
-    mCopyState->m_leftOver = 0; // reset to 0.
-    // need to reset this in case we're move/copying multiple msgs.
-    mCopyState->m_fromLineSeen = PR_FALSE;
-
+    seekableStream = do_QueryInterface(mCopyState->m_fileStream);
+    if (mCopyState->m_dummyEnvelopeNeeded)
+    {
+      PRUint32 bytesWritten;
+      seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0);
+      mCopyState->m_fileStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten);
+      if (mCopyState->m_parseMsgState)
+        mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
+    }
     // flush the copied message. We need a close at the end to get the
     // file size and time updated correctly.
-    if (mCopyState->m_fileStream)
-    {
-      seekableStream = do_QueryInterface(mCopyState->m_fileStream);
-      if (mCopyState->m_dummyEnvelopeNeeded)
-      {
-        PRUint32 bytesWritten;
-        seekableStream->Seek(nsISeekableStream::NS_SEEK_END, 0);
-        mCopyState->m_fileStream->Write(MSG_LINEBREAK, MSG_LINEBREAK_LEN, &bytesWritten);
-        if (mCopyState->m_parseMsgState)
-          mCopyState->m_parseMsgState->ParseAFolderLine(CRLF, MSG_LINEBREAK_LEN);
-      }
-      // flush the copied message. We need a close at the end to get the
-      // file size and time updated correctly.
-      if (multipleCopiesFinished)
-        mCopyState->m_fileStream->Close();
-      else
-        mCopyState->m_fileStream->Flush();
-    }
+    if (multipleCopiesFinished)
+      mCopyState->m_fileStream->Close();
+    else
+      mCopyState->m_fileStream->Flush();
   }
   //Copy the header to the new database
-  if (copySucceeded && mCopyState->m_message)
+  if (mCopyState->m_message)
   {
     //  CopyMessages() goes here, and CopyFileMessages() with metadata to save;
     nsCOMPtr<nsIMsgDBHdr> newHdr;
     if (!mCopyState->m_parseMsgState)
     {
       if (mCopyState->m_destDB)
       {
         rv = mCopyState->m_destDB->CopyHdrFromExistingHdr(mCopyState->m_curDstKey,