Closed
Bug 258018
Opened 21 years ago
Closed 18 years ago
replace nsUInt32Array with nsTArray<PRUint32>
Categories
(MailNews Core :: Backend, defect)
MailNews Core
Backend
Tracking
(Not tracked)
RESOLVED
FIXED
Future
People
(Reporter: csthomas, Assigned: neil)
References
Details
(Whiteboard: helpwanted)
Attachments
(7 files, 3 obsolete files)
1.69 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
1.82 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
2.88 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
2.65 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
15.53 KB,
patch
|
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
29.17 KB,
patch
|
Bienvenu
:
review+
Bienvenu
:
superreview+
|
Details | Diff | Splinter Review |
9.29 KB,
patch
|
Bienvenu
:
review+
|
Details | Diff | Splinter Review |
See bug 250811
Reporter | ||
Updated•21 years ago
|
Whiteboard: waiting on 250811
Updated•21 years ago
|
Product: MailNews → Core
Reporter | ||
Updated•21 years ago
|
Whiteboard: waiting on 250811 → helpwanted , waiting on 250811
Reporter | ||
Updated•21 years ago
|
Assignee: cst → sspitzer
Target Milestone: --- → Future
Reporter | ||
Updated•21 years ago
|
Whiteboard: helpwanted , waiting on 250811 → helpwanted
Comment 1•18 years ago
|
||
I'm taking a look at working around this code in Correo, and I figured I would fix this while I'm at it.
Instead of using |nsValueArray|, my proposal is to use |nsTArray| instead.
Taking...
Assignee: sspitzer → nick.kreeger
Comment 2•18 years ago
|
||
I don't know if you can completely replace nsUint32Array, but you might base it on nsTArray - we rely on things like sorting and searching a sorted nsUint32Array, especially in nsMsgKeyArray.
Assignee | ||
Comment 3•18 years ago
|
||
(In reply to comment #1)
>Instead of using |nsValueArray|, my proposal is to use |nsTArray| instead.
Yeah, nsValueArray is going away...
Summary: replace nsUInt32Array with nsValueArray → replace nsUInt32Array with nsTArray<PRUint32>
Assignee | ||
Comment 4•18 years ago
|
||
Attachment #295088 -
Flags: superreview?(bienvenu)
Attachment #295088 -
Flags: review?(bienvenu)
Assignee | ||
Comment 5•18 years ago
|
||
Attachment #295089 -
Flags: superreview?(bienvenu)
Attachment #295089 -
Flags: review?(bienvenu)
Comment 6•18 years ago
|
||
Comment on attachment 295088 [details] [diff] [review]
nsAddrBookSession patch
thx for the patch, Neil.
Attachment #295088 -
Flags: superreview?(bienvenu)
Attachment #295088 -
Flags: superreview+
Attachment #295088 -
Flags: review?(bienvenu)
Attachment #295088 -
Flags: review+
Updated•18 years ago
|
Attachment #295089 -
Flags: superreview?(bienvenu)
Attachment #295089 -
Flags: superreview+
Attachment #295089 -
Flags: review?(bienvenu)
Attachment #295089 -
Flags: review+
Assignee | ||
Comment 7•18 years ago
|
||
Attachment #295109 -
Flags: superreview?(bienvenu)
Attachment #295109 -
Flags: review?(bienvenu)
Assignee | ||
Comment 8•18 years ago
|
||
Attachment #295110 -
Flags: superreview?(bienvenu)
Attachment #295110 -
Flags: review?(bienvenu)
Updated•18 years ago
|
Attachment #295109 -
Flags: superreview?(bienvenu)
Attachment #295109 -
Flags: superreview+
Attachment #295109 -
Flags: review?(bienvenu)
Attachment #295109 -
Flags: review+
Updated•18 years ago
|
Attachment #295110 -
Flags: superreview?(bienvenu)
Attachment #295110 -
Flags: superreview+
Attachment #295110 -
Flags: review?(bienvenu)
Attachment #295110 -
Flags: review+
Comment 9•18 years ago
|
||
Attachment #295151 -
Flags: superreview?(neil)
Attachment #295151 -
Flags: review?(neil)
Assignee | ||
Comment 10•18 years ago
|
||
Comment on attachment 295151 [details] [diff] [review]
MapiMessage patch
>+ DWORD aNum = m_attachNums[idx];
Might as well make it an nsTArray<DWORD> then - see bug 410479 ;-)
Given that bug, I don't think I can fairly review this.
Attachment #295151 -
Flags: superreview?(neil)
Attachment #295151 -
Flags: review?(neil)
Assignee | ||
Comment 11•18 years ago
|
||
I had to make a bunch of pointers const because Elements() is. I should probably reformat all the affected lines while I'm there...
I removed the sorting because tree selections are already sorted.
Attachment #295678 -
Flags: superreview?(bienvenu)
Attachment #295678 -
Flags: review?(dwitte)
Updated•18 years ago
|
Attachment #295151 -
Attachment is obsolete: true
Comment 12•18 years ago
|
||
Comment on attachment 295678 [details] [diff] [review]
GetSelectedIndices patch
>Index: nsMsgDBView.cpp
>===================================================================
>@@ -1098,13 +1098,13 @@
>-nsresult nsMsgDBView::GetSelectedIndices(nsUInt32Array *selection)
>+nsresult nsMsgDBView::GetSelectedIndices(nsMsgViewIndexArray& selection)
> {
> if (mTreeSelection)
> {
> PRInt32 count;
> mTreeSelection->GetCount(&count);
>- selection->SetSize(count);
>+ selection.SetLength(count);
> count = 0;
> PRInt32 selectionCount;
> nsresult rv = mTreeSelection->GetRangeCount(&selectionCount);
>@@ -1118,7 +1118,7 @@
> if (startRange >= 0 && startRange < viewSize)
> {
> for (PRInt32 rangeIndex = startRange; rangeIndex <= endRange && rangeIndex < viewSize; rangeIndex++)
>- selection->SetAt(count++, rangeIndex);
>+ selection[count++] = rangeIndex;
doing a SetLength() call followed by assigning all the elements is efficient, but SetLength() won't zero the data like nsUInt32Array did. so if there's an early return (http://mxr.mozilla.org/mozilla/source/mailnews/base/src/nsMsgDBView.cpp#1116) and your callers don't check the return value of GetSelectedIndices() (they don't) then this is bad, no?
SetCapacity() is safer, but i'll go along with SetLength() provided you expand out that NS_ENSURE_SUCCESS to Clear() the array on failure.
>@@ -2128,17 +2128,16 @@
>- nsUInt32Array selection;
>- GetSelectedIndices(&selection);
>- *length = selection.GetSize();
>- PRUint32 numIndicies = *length;
>- if (!numIndicies) return NS_OK;
>+ nsMsgViewIndexArray selection;
>+ GetSelectedIndices(selection);
>+ PRUint32 numIndices = selection.Length();
>+ if (!numIndices) return NS_OK;
>+ *length = numIndices;
want to make the same *length/spelling fixes...
>@@ -2151,9 +2150,9 @@
>- nsUInt32Array selection;
>- GetSelectedIndices(&selection);
>- *length = selection.GetSize();
>+ nsMsgViewIndexArray selection;
>+ GetSelectedIndices(selection);
>+ *length = selection.Length();
> PRUint32 numIndicies = *length;
> if (!numIndicies) return NS_OK;
here?
r=me with those!
Attachment #295678 -
Flags: review?(dwitte) → review+
Comment 13•18 years ago
|
||
as a side note, nsAutoTArray inherits from nsTArray, so if you have code like
nsAutoTArray<foo, 2> bar;
baz(bar);
then baz can just have a signature
void baz(nsTArray<foo>& aBar);
but since you instantiate your array in a bunch of different places the typedef makes sense.
Comment 14•18 years ago
|
||
(In reply to comment #12)
> >@@ -2128,17 +2128,16 @@
> >- nsUInt32Array selection;
> >- GetSelectedIndices(&selection);
> >- *length = selection.GetSize();
> >- PRUint32 numIndicies = *length;
> >- if (!numIndicies) return NS_OK;
> >+ nsMsgViewIndexArray selection;
> >+ GetSelectedIndices(selection);
> >+ PRUint32 numIndices = selection.Length();
> >+ if (!numIndices) return NS_OK;
> >+ *length = numIndices;
>
> want to make the same *length/spelling fixes...
er wait, on second look, is that right? *length won't get set to 0 before returning.
Assignee | ||
Comment 15•18 years ago
|
||
(In reply to comment #14)
>*length won't get set to 0 before returning.
Don't worry, the out parameters are cleared early on (not enough -u, I know...)
Assignee | ||
Comment 16•18 years ago
|
||
* Updated for bitrot
* Removed the consts (I only added them because I misread nsTArray.h)
* Retained the removal of the sorting (although I thought I had to remove them so that I could add the consts, they're not actually needed anyway)
Attachment #295678 -
Attachment is obsolete: true
Attachment #300330 -
Flags: superreview?(bienvenu)
Attachment #295678 -
Flags: superreview?(bienvenu)
Comment 17•18 years ago
|
||
Comment on attachment 300330 [details] [diff] [review]
GetSelectedIndices patch
I wish I remember why were sorting the view indices, but it looks like you're right that we don't need to.
Attachment #300330 -
Flags: superreview?(bienvenu) → superreview+
Assignee | ||
Comment 18•18 years ago
|
||
Most of this is just boilerplate substitution, but somehow I couldn't let
PartitionSelectionByFolder off the hook without a rewrite. At one point I
even considered storing the indices in an nsTArray<nsTArray<PRUint32> > .
Attachment #300713 -
Flags: superreview?(bienvenu)
Attachment #300713 -
Flags: review?(bienvenu)
Comment 19•18 years ago
|
||
(In reply to comment #18)
I applied the patch this morning and recompiled and turned the Remember Message preference again. No crash after two hours worth of testing. I haven't been run that long with normal mail usage in the past 12 days. So far I like it. Will post results after a full day in a few hours; but if others can apply the diff and test I think you'd appreciate the results! :)
Comment 20•18 years ago
|
||
(In reply to comment #19)
ARGH! WRONG BUG!!! Comment 19 is not valid for this bug! :)
Comment 21•18 years ago
|
||
Comment on attachment 300713 [details] [diff] [review]
Most of the rest
thx, Neil.
Can you just remove these comment lines?
// m_idArray.RemoveAll();
- // m_flags.RemoveAll();
+ // m_flags.Clear();
Attachment #300713 -
Flags: superreview?(bienvenu)
Attachment #300713 -
Flags: superreview+
Attachment #300713 -
Flags: review?(bienvenu)
Attachment #300713 -
Flags: review+
Assignee | ||
Comment 22•18 years ago
|
||
The only remaining consumer of nsUInt32Array is nsMsgKeyArray, which is being dealt with in a separate bug. Even then we can't simply remove the header file because three files are relying on it to include prmem.h; this patch fixes that.
For nsMessenger.cpp the allocations are all wrong so I fixed them.
For nsMsgDBView.cpp we need to be able to free the Allocate(d)RawSortKey.
For nsMsgUtils.cpp the ns_MsgSA* functions should be replaced by nsCString...
Assignee | ||
Comment 23•18 years ago
|
||
Including some more allocator mismatches too.
Attachment #303165 -
Attachment is obsolete: true
Attachment #303271 -
Flags: review?(bienvenu)
Attachment #303165 -
Flags: review?(bienvenu)
Comment 24•18 years ago
|
||
Comment on attachment 303271 [details] [diff] [review]
Fix more includes
getting rid of PR_CALLOC and +1 alloc size looks OK.
Attachment #303271 -
Flags: review?(bienvenu) → review+
Assignee | ||
Comment 25•18 years ago
|
||
This bug is now fixed.
Bug 413413 will actually remove nsUInt32ARray.* as nsMsgKeyArray still uses it.
Status: ASSIGNED → RESOLVED
Closed: 18 years ago
Resolution: --- → FIXED
Updated•17 years ago
|
Product: Core → MailNews Core
You need to log in
before you can comment on or make changes to this bug.
Description
•