Closed
Bug 325331
Opened 20 years ago
Closed 20 years ago
Make nsTArray a bit more useful
Categories
(Core :: XPCOM, enhancement)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla1.9alpha1
People
(Reporter: darin.moz, Assigned: darin.moz)
Details
(Keywords: fixed1.8.1)
Attachments
(2 files)
|
9.34 KB,
patch
|
benjamin
:
review+
benjamin
:
approval-branch-1.8.1+
|
Details | Diff | Splinter Review |
|
10.54 KB,
patch
|
Details | Diff | Splinter Review |
Make nsTArray a bit more useful:
1. Support Append, Insert, and Replace from items of type A on an array of
type B, provided instances of B can be constructed from A.
2. Return pointer to newly constructed elements from Append, Insert, and
Replace instead of a boolean flag.
The first change (#1) will make the following code more efficient:
nsTArray<nsCString> ary;
ary.AppendElement("foo");
Previously, this code was supported, but it resulted in a temporary nsCString being created. That temporary is eliminated by #1.
The second change (#2) is just a nice to have for consistency with the versions of Append and Insert that construct an element using the element's default constructor.
| Assignee | ||
Comment 1•20 years ago
|
||
I've only verified that this compiles on VC7.1, but I have a feeling that it will work elsewhere too. Crossing my fingers ;-)
Attachment #210243 -
Flags: review?(benjamin)
| Assignee | ||
Updated•20 years ago
|
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.9alpha
Comment 2•20 years ago
|
||
Comment on attachment 210243 [details] [diff] [review]
v1 patch
Nested templates should work, let's find out when you checkin ;-)
Attachment #210243 -
Flags: review?(benjamin) → review+
| Assignee | ||
Comment 3•20 years ago
|
||
fixed-on-trunk
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 4•20 years ago
|
||
It looks like creature was unhappy with this change:
TestTArray.cpp
../../dist/include/xpcom\nsTArray.h(238) : error C2667: 'ReplaceElementsAt' : none of 2 overload have a best conversion
../../dist/include/xpcom\nsTArray.h(237) : while compiling class-template member function 'class nsTArray<class nsCString> &__thiscall nsTArray<class nsCString>::operator =(const class nsTArray<class nsCString> &)'
../../dist/include/xpcom\nsTArray.h(238) : error C2668: 'ReplaceElementsAt' : ambiguous call to overloaded function
../../dist/include/xpcom\nsTArray.h(237) : while compiling class-template member function 'class nsTArray<class nsCString> &__thiscall nsTArray<class nsCString>::operator =(const class nsTArray<class nsCString> &)'
make[5]: *** [TestTArray.obj] Error 2
I decided to back this patch out until I have a chance to debug it on a system with VC6.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
| Assignee | ||
Comment 5•20 years ago
|
||
Relanded this patch w/ a fix for VC6.
Status: REOPENED → RESOLVED
Closed: 20 years ago → 20 years ago
Resolution: --- → FIXED
| Assignee | ||
Comment 6•20 years ago
|
||
Comment on attachment 210243 [details] [diff] [review]
v1 patch
I'd like to keep nsTArray in sync between trunk and 1.8 branch if possible since the class is used by places.
Attachment #210243 -
Flags: branch-1.8.1?(benjamin)
Comment 7•20 years ago
|
||
Comment on attachment 210243 [details] [diff] [review]
v1 patch
What was the VC6 fix?
Attachment #210243 -
Flags: branch-1.8.1?(benjamin) → branch-1.8.1+
| Assignee | ||
Comment 8•20 years ago
|
||
I modified the copy constructor to call the 4 argument version of ReplaceElementsAt instead of the 3 argument version. Interestingly enough, the 4 argument version works fine when called directly or indirectly via InsertElementsAt. It was just some problem related to the copy constructor that was tripping up VC6 apparently.
| Assignee | ||
Comment 9•20 years ago
|
||
Here's the patch for the 1.8 branch.
You need to log in
before you can comment on or make changes to this bug.
Description
•