Closed
Bug 88344
Opened 24 years ago
Closed 24 years ago
Add sorting capabilities in nsVoidArray & nsStringArray
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla0.9.3
People
(Reporter: rbs, Assigned: rbs)
Details
(Whiteboard: Have fix, have r=dbaron, need sr=)
Attachments
(5 files)
I am going to attach a patch that allows sorting the mImpl->mArray in
nsVoidArray. Due to the lack of an in-place sorting ability, people are copying
the array in their own buffer when they are about to sort it. The patch will
remdy the situation.
The methods added:
void nsVoidArray::Sort(nsVoidArrayComparatorFunc aFunc, void* aData);
void nsStringArray::Sort(void);
void nsStringArray::SortIgnoreCase(void);
void nsCStringArray::Sort(void);
void nsCStringArray::SortIgnoreCase(void);
They all boil down to calling NS_QuickSort on mImpl->mArray. And the string
variants further default to the existing comparators in nsAString.h.
Status: NEW → ASSIGNED
Whiteboard: Have fix since 2001-06-29, need r=, sr=
Target Milestone: --- → mozilla0.9.3
Comment 2•24 years ago
|
||
Do you know where people are sorting the array themselves by copying so that we
can file bugs on those and fix it?
Here is an example:
http://lxr.mozilla.org/seamonkey/source/intl/uconv/src/nsCharsetMenu.cpp#1471
Also, perhaps some people may be staying away from nsVoidArray in certain areas
where they are anticipating that they will need sorting capabilities.
I had a similar patch for just nsVoidArray in bug 74920. I preferred the API I
had for nsVoidArray, because while it was slightly less efficient, it was less
confusing, since the caller got their pointer back rather than a pointer to it.
r=dbaron, if you've tested it appropriately
Tested (on Win32). I will sprinkle some debugging assertions to null check
pointers and catch bad callers when checking in.
... and also use NS_STATIC_CAST per the local custom over there.
| Assignee | ||
Comment 10•24 years ago
|
||
OK, added the static cast -- didn't add the asertions (not in the local custom,
and will crash immediately anyway), and fixed an XXX comment that was on my way,
and which cvs blame said was a remnant of the heat of the XPCDOM landing.
Need sr= to be done with this one. Thanks.
Whiteboard: Have fix since 2001-06-29, need r=, sr= → Have fix, have r=dbaron, need sr=
One additional comment that I just thought of: it might be good to have (for
lack of widespread support for |using|) an inline method on ns[C]StringArray
that prevents the nsVoidArray::Sort from being hidden, i.e.:
void Sort(nsVoidArrayComparatorFunc aFunc, void* aData)
{
nsVoidArray::Sort(aFunc, aData);
}
| Assignee | ||
Comment 12•24 years ago
|
||
| Assignee | ||
Comment 13•24 years ago
|
||
Comment 14•24 years ago
|
||
Let's have scc sr= this one, as he's the one with his heart setting on making
xpcom/ds a cleaner, safer, drug-free place.
| Assignee | ||
Comment 15•24 years ago
|
||
scc, seeking your sr= to land this little gem. Thanks.
Comment 16•24 years ago
|
||
works for me, sr=scc
| Assignee | ||
Comment 17•24 years ago
|
||
Thanks guys, patch landed, resolving as FIXED.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
You need to log in
before you can comment on or make changes to this bug.
Description
•