Closed
Bug 686597
Opened 13 years ago
Closed 13 years ago
nsAutoTArray doesn't have a copy-constructor.
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla9
People
(Reporter: justin.lebar+bug, Assigned: justin.lebar+bug)
References
Details
Attachments
(1 file, 1 obsolete file)
1.67 KB,
patch
|
bzbarsky
:
review+
|
Details | Diff | Splinter Review |
In bug 682735 comment 52, we noticed that nsAutoTArray doesn't have a copy-constructor. The following code: nsAutoTArray<E, 16> foo; // put some elements in foo nsAutoTArray<E, 16> bar(foo); effectively makes |bar| a nsTArray; |bar| will never use its auto storage. We can fix this simply by adding copy constructors.
Assignee | ||
Updated•13 years ago
|
Assignee: nobody → justin.lebar+bug
Assignee | ||
Comment 1•13 years ago
|
||
Luke pointed out that js vectors don't have copy constructors -- if you want to copy a vector, you need to do so explicitly. I'm going to see whether we can just do that here.
Assignee | ||
Comment 2•13 years ago
|
||
Well, nsTArray has a copy-constructor, and I'm not sure we're ready to get rid of that. So maybe nsAutoTArray should also have one.
Assignee | ||
Comment 3•13 years ago
|
||
I need to test that this fixes the issues we saw in bug 682735 comment 52, but unfortunately my instrumentation doesn't work on mac. I think this should work...
Attachment #560281 -
Flags: review?(bzbarsky)
Comment 4•13 years ago
|
||
Comment on attachment 560281 [details] [diff] [review] Add a copy constructor to nsAutoTArray and friends. >+++ b/xpcom/glue/nsTArray.h >+ nsAutoArrayBase(const nsAutoArrayBase<TArrayBase, N> &aOther) { Any reason to not make that argument |const TArrayBase &aOther|? r=me either way.
Attachment #560281 -
Flags: review?(bzbarsky) → review+
Assignee | ||
Comment 5•13 years ago
|
||
(In reply to Boris Zbarsky (:bz) from comment #4) > >+++ b/xpcom/glue/nsTArray.h > >+ nsAutoArrayBase(const nsAutoArrayBase<TArrayBase, N> &aOther) { > > Any reason to not make that argument |const TArrayBase &aOther|? I think just to emphasize that the constructor shouldn't be called except by nsAutoArrayBase's children's copy-constructors. But in that case, maybe it should be protected...
OS: Mac OS X → Windows Mobile 6 Professional
Assignee | ||
Updated•13 years ago
|
OS: Windows Mobile 6 Professional → All
Hardware: x86 → All
Assignee | ||
Comment 6•13 years ago
|
||
Making the constructors protected.
Attachment #560504 -
Flags: review?(bzbarsky)
Assignee | ||
Updated•13 years ago
|
Attachment #560281 -
Attachment is obsolete: true
Comment 7•13 years ago
|
||
Comment on attachment 560504 [details] [diff] [review] Patch v2 r=me
Attachment #560504 -
Flags: review?(bzbarsky) → review+
Comment 8•13 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/304a0a282365
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla9
You need to log in
before you can comment on or make changes to this bug.
Description
•