Closed
Bug 413413
Opened 18 years ago
Closed 5 years ago
Replace nsMsgKeyArray with nsTArray<nsMsgKey>
Categories
(MailNews Core :: Backend, defect)
MailNews Core
Backend
Tracking
(thunderbird_esr78 unaffected)
RESOLVED
FIXED
| Tracking | Status | |
|---|---|---|
| thunderbird_esr78 | --- | unaffected |
People
(Reporter: neil, Assigned: neil)
References
Details
Attachments
(8 files, 1 obsolete file)
|
46.80 KB,
patch
|
Details | Diff | Splinter Review | |
|
24.22 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
22.86 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
5.71 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
11.33 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
11.42 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
200.66 KB,
patch
|
dwitte
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
|
37.37 KB,
patch
|
Details | Diff | Splinter Review |
See bug 258018
| Assignee | ||
Comment 1•18 years ago
|
||
| Assignee | ||
Comment 2•18 years ago
|
||
I was going to start by converting GetAt to operator[] but that doesn't work so nicely for pointers so instead I started by turning them into references.
I added an overload for a writable operator[], this allows me to convert SetAt to operator[] too, but so far I have only used it for these references.
nsTArray's operator [] is also writable of course.
I also removed a pointless-looking override of DeleteMessages().
Assignee: nobody → neil
Status: NEW → ASSIGNED
Attachment #303419 -
Flags: superreview?(bienvenu)
Attachment #303419 -
Flags: review?(bienvenu)
| Assignee | ||
Comment 3•18 years ago
|
||
Attachment #304804 -
Flags: superreview?(bienvenu)
Attachment #304804 -
Flags: review?(bienvenu)
| Assignee | ||
Comment 4•18 years ago
|
||
Since taking the address of a variable results in an array of one element.
Attachment #304833 -
Flags: superreview?(bienvenu)
Attachment #304833 -
Flags: review?(bienvenu)
Comment 5•18 years ago
|
||
Comment on attachment 303419 [details] [diff] [review]
Pass arrays by reference
nice, thx.
Attachment #303419 -
Flags: superreview?(bienvenu)
Attachment #303419 -
Flags: superreview+
Attachment #303419 -
Flags: review?(bienvenu)
Attachment #303419 -
Flags: review+
Comment 6•18 years ago
|
||
Comment on attachment 304833 [details] [diff] [review]
Don't create arrays of one key
coulda swore I reviewed this...but bugzilla doesn't lie.
Attachment #304833 -
Flags: superreview?(bienvenu)
Attachment #304833 -
Flags: superreview+
Attachment #304833 -
Flags: review?(bienvenu)
Attachment #304833 -
Flags: review+
Updated•18 years ago
|
Attachment #304804 -
Flags: superreview?(bienvenu)
Attachment #304804 -
Flags: superreview+
Attachment #304804 -
Flags: review?(bienvenu)
Attachment #304804 -
Flags: review+
| Assignee | ||
Comment 7•18 years ago
|
||
I've also removed SetAt and made SetAtGrow and GetAt protected (operator[] uses it) which turned up a case missed by attachment 304804 [details] [diff] [review].
Attachment #307685 -
Flags: superreview?(bienvenu)
Attachment #307685 -
Flags: review?(bienvenu)
| Assignee | ||
Comment 8•18 years ago
|
||
* Simplify nsMsgSearchNews::CollateHits
* Simplify one use of SetAt in a different way
* Switch nsImapMoveCoalescer to use nsTArray instead of nsVoidArray
* Fix a one-key array in nsMsgComposeSendListener I missed earlier
Attachment #308351 -
Flags: superreview?(bienvenu)
Attachment #308351 -
Flags: review?(bienvenu)
Updated•18 years ago
|
Attachment #307685 -
Flags: superreview?(bienvenu)
Attachment #307685 -
Flags: superreview+
Attachment #307685 -
Flags: review?(bienvenu)
Attachment #307685 -
Flags: review+
Updated•18 years ago
|
Attachment #308351 -
Flags: superreview?(bienvenu)
Attachment #308351 -
Flags: superreview+
Attachment #308351 -
Flags: review?(bienvenu)
Attachment #308351 -
Flags: review+
| Assignee | ||
Comment 9•18 years ago
|
||
25% down, this is the last 75%!
Attachment #309508 -
Flags: superreview?(bienvenu)
Attachment #309508 -
Flags: review?(dwitte)
Comment 10•18 years ago
|
||
Comment on attachment 309508 [details] [diff] [review]
The Big One
i see a lot of instances of |somearray.Length() > 0| and variations throughout the patch... can you switch them to use IsEmpty() instead? you should be able to search through the diff for .Length() > 0, .Length() == 0. there are also a few cases of |if (array.Length())| which you should be able to catch by searching for .Length())...
>Index: mailnews/base/search/src/nsMsgSearchNews.cpp
>===================================================================
>- m_candidateHits.QuickSort(CompareArticleNumbers);
>+ m_candidateHits.Sort();
ohh, such beautiful template syntactic sugar ;)
>Index: mailnews/base/src/nsMsgDBView.cpp
>===================================================================
>@@ -764,7 +764,7 @@ nsresult nsMsgDBView::SaveAndClearSelect
>- aMsgKeyArray.SetSize(numIndices);
>+ aMsgKeyArray.SetLength(numIndices);
are we sure not to run into more topcrashiness with this? as long as you've manually verified that this, and each case below, is safe then i'm happy.
>@@ -4844,7 +4830,7 @@ nsresult nsMsgDBView::ListIdsInThread(ns
>- m_keys.InsertAt(viewIndex, 0, numChildren);
>+ m_keys.InsertElementsAt(viewIndex, numChildren);
topcrashiness again, maybe |m_keys.InsertElementsAt(viewIndex, numChildren, 0);| ?
>@@ -5229,7 +5215,7 @@ nsresult nsMsgDBView::MarkThreadRead(nsI
>- idsMarkedRead.AllocateSpace(numChildren);
>+ idsMarkedRead.SetCapacity(numChildren);
topcrashiness - AllocateSpace zeros the array too, is it safe?
>Index: mailnews/base/src/nsMsgGroupThread.cpp
>===================================================================
>@@ -298,7 +298,7 @@ nsresult nsMsgGroupThread::RemoveChild(n
> {
> PRUint32 childIndex = m_keys.IndexOf(msgKey);
> if (childIndex != kNotFound)
>- m_keys.RemoveAt(childIndex);
>+ m_keys.RemoveElementAt(childIndex);
|m_keys.RemoveElement(msgKey);|
>Index: mailnews/base/src/nsMsgGroupView.cpp
>===================================================================
>@@ -539,7 +539,7 @@ nsresult nsMsgQuickSearchDBView::ListId
>- if ( index > ((nsMsgViewIndex) m_keys.GetSize()))
>+ if (index > ((nsMsgViewIndex) m_keys.Length()))
> return NS_MSG_MESSAGE_NOT_FOUND;
looks suspicious - does this want >=?
>Index: mailnews/base/src/nsMsgThreadedDBView.cpp
>===================================================================
>@@ -186,7 +186,7 @@ nsresult nsMsgThreadedDBView::SortThread
>- m_keys.SetSize(numThreads);
>+ m_keys.SetLength(numThreads);
>@@ -238,7 +238,7 @@ nsresult nsMsgThreadedDBView::AddKeys(ns
>- m_keys.AllocateSpace(numKeysToAdd+m_keys.GetSize());
>+ m_keys.SetCapacity(m_keys.Length() + numKeysToAdd);
>Index: mailnews/base/util/nsMsgDBFolder.cpp
>===================================================================
>@@ -1996,7 +1996,6 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
>- m_saveNewMsgs.RemoveAll();
is this right?
>Index: mailnews/imap/src/nsImapFlagAndUidState.cpp
>===================================================================
>@@ -120,7 +120,7 @@ nsImapFlagAndUidState::nsImapFlagAndUidS
>- fUids.SetSize(fNumberOfMessageSlotsAllocated);
>+ fUids.SetLength(fNumberOfMessageSlotsAllocated);
>@@ -224,7 +224,7 @@ NS_IMETHODIMP nsImapFlagAndUidState::Add
>- fUids.SetSize(fNumberOfMessageSlotsAllocated);
>+ fUids.SetLength(fNumberOfMessageSlotsAllocated);
>Index: mailnews/imap/src/nsImapMailFolder.cpp
>===================================================================
>@@ -2507,12 +2505,12 @@ NS_IMETHODIMP nsImapMailFolder::UpdateIm
>- if (keysToDelete.GetSize() && mDatabase)
>+ if (keysToDelete.Length() && mDatabase)
pointing this one out since the search won't catch it.
r=me with those fixes!
Attachment #309508 -
Flags: review?(dwitte) → review+
| Assignee | ||
Comment 11•18 years ago
|
||
(In reply to comment #10)
>(From update of attachment 309508 [details] [diff] [review])
>i see a lot of instances of |somearray.Length() > 0| and variations throughout
>the patch... can you switch them to use IsEmpty() instead?
Done.
>>Index: mailnews/base/search/src/nsMsgSearchNews.cpp
>>===================================================================
>>- m_candidateHits.QuickSort(CompareArticleNumbers);
>>+ m_candidateHits.Sort();
>ohh, such beautiful template syntactic sugar ;)
Ironically QuickSort has a default argument...
>>Index: mailnews/base/src/nsMsgDBView.cpp
>>===================================================================
>>@@ -764,7 +764,7 @@ nsresult nsMsgDBView::SaveAndClearSelect
>>- aMsgKeyArray.SetSize(numIndices);
>>+ aMsgKeyArray.SetLength(numIndices);
>are we sure not to run into more topcrashiness with this? as long as you've
>manually verified that this, and each case below, is safe then i'm happy.
This is safe, we overwrite all the indices.
>>@@ -4844,7 +4830,7 @@ nsresult nsMsgDBView::ListIdsInThread(ns
>>- m_keys.InsertAt(viewIndex, 0, numChildren);
>>+ m_keys.InsertElementsAt(viewIndex, numChildren);
> topcrashiness again, maybe |m_keys.InsertElementsAt(viewIndex, numChildren,
> 0);| ?
Good catch.
>>@@ -5229,7 +5215,7 @@ nsresult nsMsgDBView::MarkThreadRead(nsI
>>- idsMarkedRead.AllocateSpace(numChildren);
>>+ idsMarkedRead.SetCapacity(numChildren);
>topcrashiness - AllocateSpace zeros the array too, is it safe?
Again, we overwrite all the entries here.
>>Index: mailnews/base/src/nsMsgGroupThread.cpp
>>===================================================================
>>@@ -298,7 +298,7 @@ nsresult nsMsgGroupThread::RemoveChild(n
>> {
>> PRUint32 childIndex = m_keys.IndexOf(msgKey);
>> if (childIndex != kNotFound)
>>- m_keys.RemoveAt(childIndex);
>>+ m_keys.RemoveElementAt(childIndex);
>|m_keys.RemoveElement(msgKey);|
Nice.
>
>>Index: mailnews/base/src/nsMsgQuickSearchDBView.cpp
>>===================================================================
>>@@ -539,7 +539,7 @@ nsresult nsMsgQuickSearchDBView::ListId
>>- if ( index > ((nsMsgViewIndex) m_keys.GetSize()))
>>+ if (index > ((nsMsgViewIndex) m_keys.Length()))
>looks suspicious - does this want >=?
Not my bug but I'll fix it ;-)
>>Index: mailnews/base/src/nsMsgThreadedDBView.cpp
>>===================================================================
>>@@ -186,7 +186,7 @@ nsresult nsMsgThreadedDBView::SortThread
>>- m_keys.SetSize(numThreads);
>>+ m_keys.SetLength(numThreads);
This is shrinking the array.
>>@@ -238,7 +238,7 @@ nsresult nsMsgThreadedDBView::AddKeys(ns
>>- m_keys.AllocateSpace(numKeysToAdd+m_keys.GetSize());
>>+ m_keys.SetCapacity(m_keys.Length() + numKeysToAdd);
Allocate space doesn't change the length, it just makes appending faster.
>>Index: mailnews/base/util/nsMsgDBFolder.cpp
>>===================================================================
>>@@ -1996,7 +1996,6 @@ nsMsgDBFolder::CallFilterPlugins(nsIMsgW
>>- m_saveNewMsgs.RemoveAll();
>is this right?
Earlier I swapped it with an empty array so it's already empty.
>>Index: mailnews/imap/src/nsImapFlagAndUidState.cpp
>>===================================================================
>>@@ -120,7 +120,7 @@ nsImapFlagAndUidState::nsImapFlagAndUidS
>>- fUids.SetSize(fNumberOfMessageSlotsAllocated);
>>+ fUids.SetLength(fNumberOfMessageSlotsAllocated);
>>@@ -224,7 +224,7 @@ NS_IMETHODIMP nsImapFlagAndUidState::Add
>>- fUids.SetSize(fNumberOfMessageSlotsAllocated);
>>+ fUids.SetLength(fNumberOfMessageSlotsAllocated);
Fixed to use InsertElementsAt (3-arg version that initialises the elements).
>>Index: mailnews/imap/src/nsImapMailFolder.cpp
>>===================================================================
>>@@ -2507,12 +2505,12 @@ NS_IMETHODIMP nsImapMailFolder::UpdateIm
>>- if (keysToDelete.GetSize() && mDatabase)
>>+ if (keysToDelete.Length() && mDatabase)
>pointing this one out since the search won't catch it.
My search was slightly different so I did in fact spot it but thanks anyway.
| Assignee | ||
Comment 12•18 years ago
|
||
(See comment #11)
Attachment #309508 -
Attachment is obsolete: true
Attachment #309685 -
Flags: superreview?(bienvenu)
Attachment #309685 -
Flags: review?(dwitte)
Attachment #309508 -
Flags: superreview?(bienvenu)
Updated•18 years ago
|
Attachment #309685 -
Flags: review?(dwitte) → review+
Comment 13•18 years ago
|
||
Comment on attachment 309685 [details] [diff] [review]
Addressed review comments
>Index: mailnews/base/src/nsMsgDBView.cpp
>===================================================================
>@@ -4245,7 +4234,7 @@ nsresult nsMsgDBView::ExpansionDelta(nsM
>- if ( index > ((nsMsgViewIndex) m_keys.GetSize()))
>+ if ( index > ((nsMsgViewIndex) m_keys.Length()))
> return NS_MSG_MESSAGE_NOT_FOUND;
just spotted this one too, since you're fixing one you should fix the other :)
nice stuff!
Comment 14•18 years ago
|
||
Comment on attachment 309685 [details] [diff] [review]
Addressed review comments
whew, that was a big patch!
Attachment #309685 -
Flags: superreview?(bienvenu) → superreview+
| Assignee | ||
Comment 15•18 years ago
|
||
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Comment 16•18 years ago
|
||
Tried an hourly, since this was so big a checkin:
Crash on startup
http://crash-stats.mozilla.com/report/index/4bb9531c-f6f5-11dc-a575-001a4bd43ed6?date=2008-03-21-03
This checkin?
Comment 17•18 years ago
|
||
http://crash-stats.mozilla.com/report/list?range_unit=days&query_search=signature&query_type=contains&product=SeaMonkey%2CThunderbird&branch=1.9&signature=%400x0&range_value=1 all seem to be the same stack and I heavily suspect this patch as the cause.
Updated•17 years ago
|
Product: Core → MailNews Core
Updated•5 years ago
|
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Updated•5 years ago
|
Assignee: neil → benc
Comment 18•5 years ago
•
|
||
Still vestiges of nsMsgKeyArray in there.
Here's another patch to remove it, then we can revisit it in another 13 years :-)
Attachment #9197657 -
Flags: review?(mkmelin+mozilla)
Comment 19•5 years ago
|
||
try run (not the exact patch, but close enough - I just tweaked some comments and rebased it):
https://treeherder.mozilla.org/jobs?repo=try-comm-central&revision=995f912a449fefffc196570780220a3ddfb495c2
Comment 20•5 years ago
|
||
Comment on attachment 9197657 [details] [diff] [review]
413413-remove-nsMsgKeyArray-1.patch
Review of attachment 9197657 [details] [diff] [review]:
-----------------------------------------------------------------
It's confusing reopening a 13yr old bug. Let's move the patch to a new bug...
::: mailnews/db/msgdb/public/nsIMsgDatabase.idl
@@ +297,5 @@
> * Returns all message keys stored in the database.
> * Keys are returned in the order as stored in the database.
> * The caller should sort them if it needs to.
> */
> + Array<nsMsgKey> ListAllKeys();
might as well change to listAllKeys() while we're changing
::: mailnews/db/msgdb/src/nsMsgDatabase.cpp
@@ +4465,1 @@
> nsresult rv = ListAllKeys(keys);
this rv shouldn't be ignored
@@ +4477,5 @@
> subject.get());
> }
> }
> nsTArray<nsMsgKey> threads;
> rv = ListAllThreads(&threads);
and this
::: mailnews/local/src/nsPop3IncomingServer.cpp
@@ +135,1 @@
> rv = subFolderDB->ListAllKeys(keys);
this rv shouldn't be ignored
Attachment #9197657 -
Flags: review?(mkmelin+mozilla)
Updated•5 years ago
|
Status: REOPENED → RESOLVED
Closed: 18 years ago → 5 years ago
Resolution: --- → INCOMPLETE
Updated•5 years ago
|
You need to log in
before you can comment on or make changes to this bug.
Description
•