Closed
Bug 1185763
Opened 9 years ago
Closed 9 years ago
Rename deceptively named nsTArray::MoveElementsFrom
Categories
(Core :: XPCOM, defect)
Core
XPCOM
Tracking
()
RESOLVED
FIXED
mozilla45
People
(Reporter: poiru, Assigned: poiru)
Details
Attachments
(7 files)
19.63 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
16.53 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
2.02 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
1.24 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
3.83 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
2.30 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
1.31 KB,
patch
|
froydnj
:
review+
froydnj
:
feedback+
|
Details | Diff | Splinter Review |
As seen in bug 1185759, nsTArray::MoveElementsFrom is not the best name. I think we should rename it to something like AppendRawElements. Nathan, any thoughts?
Flags: needinfo?(nfroyd)
Assignee | ||
Comment 1•9 years ago
|
||
(In reply to Birunthan Mohanathas [:poiru] from comment #0) > As seen in bug 1185759, nsTArray::MoveElementsFrom is not the best name. I > think we should rename it to something like AppendRawElements. Nathan, any > thoughts? Gah, I meant to say AppendMovedElements. Also, I think we should remove the non-r-value reference version of MoveElementsFrom to make the intent clear.
Comment 2•9 years ago
|
||
AppendMovedElements WFM. Is MoveElementsFrom actually doing C++-level moving currently?
Flags: needinfo?(nfroyd)
Assignee | ||
Comment 3•9 years ago
|
||
(In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #2) > AppendMovedElements WFM. Is MoveElementsFrom actually doing C++-level > moving currently? Nope. I decided to go with 'Merge' as I think that describes the intent more clearly.
Assignee | ||
Comment 4•9 years ago
|
||
Attachment #8637247 -
Flags: review?(nfroyd)
Assignee | ||
Comment 5•9 years ago
|
||
Attachment #8637248 -
Flags: review?(nfroyd)
Assignee | ||
Comment 6•9 years ago
|
||
Attachment #8637249 -
Flags: review?(nfroyd)
Assignee | ||
Comment 7•9 years ago
|
||
Attachment #8637250 -
Flags: review?(nfroyd)
Comment 8•9 years ago
|
||
I don't know what the right name is, but I don't think Merge is the right name, as that tends to get used for sorting algorithms...
Assignee | ||
Comment 9•9 years ago
|
||
(In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #8) > I don't know what the right name is, but I don't think Merge is the right > name, as that tends to get used for sorting algorithms... How about just AppendArray, then? Together with Part 2, I think that is a sufficiently descriptive name.
Comment 10•9 years ago
|
||
(In reply to Birunthan Mohanathas [:poiru] from comment #9) > (In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #8) > > I don't know what the right name is, but I don't think Merge is the right > > name, as that tends to get used for sorting algorithms... > > How about just AppendArray, then? Together with Part 2, I think that is a > sufficiently descriptive name. If we're going to do that, why not just add an infallible-only nsTArray&& overload to AppendElements?
Updated•9 years ago
|
Attachment #8637246 -
Flags: review?(nfroyd) → review+
Updated•9 years ago
|
Attachment #8637249 -
Flags: review?(nfroyd) → review+
Updated•9 years ago
|
Attachment #8637250 -
Flags: review?(nfroyd) → review+
Updated•9 years ago
|
Attachment #8637247 -
Flags: review?(nfroyd) → review+
Updated•9 years ago
|
Attachment #8637248 -
Flags: review?(nfroyd) → review+
Comment 11•9 years ago
|
||
Probably easiest to do the renaming as a part 6 followup if we go with AppendElements(nsTArray&&). Tests would also be appreciated to make sure we get this right.
Assignee | ||
Comment 12•9 years ago
|
||
I modified my local patches to use AppendElements as per comment 11.
Attachment #8638008 -
Flags: review?(nfroyd)
Assignee | ||
Comment 13•9 years ago
|
||
Attachment #8638009 -
Flags: review?(nfroyd)
Comment 14•9 years ago
|
||
Comment on attachment 8638009 [details] [diff] [review] Part 7: Add test for r-value nsTArray::AppendElements Review of attachment 8638009 [details] [diff] [review]: ----------------------------------------------------------------- As fine as these tests are, I think it'd be better to have something like: class MoveChecker { public: MoveChecker() { sNormalConstructs++; } MoveChecker(const MoveChecker&) { ...; sCopyConstructs++; } MoveChecker(MoveChecker&&) { ...; sMoveConstructs++; } ... }; etc. similar to what test_move_array in TestTArray.cpp already does (maybe you can even reuse Countable and Movable?). Then assert that the counts are what you expect after each operation, in addition to asserting properties of the array itself.
Attachment #8638009 -
Flags: review?(nfroyd) → feedback+
Comment 15•9 years ago
|
||
Comment on attachment 8638008 [details] [diff] [review] Part 6: Add fallible variant of r-value nsTArray::AppendElements Review of attachment 8638008 [details] [diff] [review]: ----------------------------------------------------------------- ::: xpcom/glue/nsTArray.h @@ +1542,1 @@ > elem_type* AppendElements(nsTArray_Impl<Item, Allocator>&& aArray) I forget; we want to unprotect this eventually, correct?
Attachment #8638008 -
Flags: review?(nfroyd) → review+
Assignee | ||
Comment 16•9 years ago
|
||
Comment on attachment 8638009 [details] [diff] [review] Part 7: Add test for r-value nsTArray::AppendElements (In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #14) > Comment on attachment 8638009 [details] [diff] [review] > Part 7: Add test for r-value nsTArray::AppendElements > > Review of attachment 8638009 [details] [diff] [review]: > ----------------------------------------------------------------- > > As fine as these tests are, I think it'd be better to have something like: > > class MoveChecker > { > public: > MoveChecker() { sNormalConstructs++; } > MoveChecker(const MoveChecker&) { ...; sCopyConstructs++; } > MoveChecker(MoveChecker&&) { ...; sMoveConstructs++; } > ... > }; > > etc. similar to what test_move_array in TestTArray.cpp already does (maybe > you can even reuse Countable and Movable?). Then assert that the counts are > what you expect after each operation, in addition to asserting properties of > the array itself. With the r-value version of AppendElements, we just steal the bits of the given array rather than invoking the move constructor or move assignment operator. Therefore, I don't think the Moveable class would be appropriate here. I'm rerequesting review in hopes that you agree. (In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #15) > Comment on attachment 8638008 [details] [diff] [review] > Part 6: Add fallible variant of r-value nsTArray::AppendElements > > Review of attachment 8638008 [details] [diff] [review]: > ----------------------------------------------------------------- > > ::: xpcom/glue/nsTArray.h > @@ +1542,1 @@ > > elem_type* AppendElements(nsTArray_Impl<Item, Allocator>&& aArray) > > I forget; we want to unprotect this eventually, correct? Yep, that'll happen after we switch (most) uses of FallibleTArray to nsTArray.
Attachment #8638009 -
Flags: review?(nfroyd)
Comment 17•9 years ago
|
||
(In reply to Birunthan Mohanathas [:poiru] from comment #16) > (In reply to Nathan Froyd [:froydnj][:nfroyd] from comment #14) > > class MoveChecker > > { > > public: > > MoveChecker() { sNormalConstructs++; } > > MoveChecker(const MoveChecker&) { ...; sCopyConstructs++; } > > MoveChecker(MoveChecker&&) { ...; sMoveConstructs++; } > > ... > > }; > > > > etc. similar to what test_move_array in TestTArray.cpp already does (maybe > > you can even reuse Countable and Movable?). Then assert that the counts are > > what you expect after each operation, in addition to asserting properties of > > the array itself. > > With the r-value version of AppendElements, we just steal the bits of the > given array rather than invoking the move constructor or move assignment > operator. Therefore, I don't think the Moveable class would be appropriate > here. I'm rerequesting review in hopes that you agree. I'm assuming that by "steal the bits", you mean "blast them into place with memcpy/memmove", correct? That doesn't necessarily happen for all types, e.g. http://mxr.mozilla.org/mozilla-central/source/xpcom/glue/nsTArray.h#670 and looking at the code, I don't think we get this right now...
Comment 18•9 years ago
|
||
Comment on attachment 8638009 [details] [diff] [review] Part 7: Add test for r-value nsTArray::AppendElements Review of attachment 8638009 [details] [diff] [review]: ----------------------------------------------------------------- Actually, let's fix the move issues in another bug. They are orthogonal to the issues being addressed here.
Attachment #8638009 -
Flags: review?(nfroyd) → review+
Comment 19•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/9f00f5621fca https://hg.mozilla.org/integration/mozilla-inbound/rev/d35a4a640099 https://hg.mozilla.org/integration/mozilla-inbound/rev/ca1f72e930c4 https://hg.mozilla.org/integration/mozilla-inbound/rev/f6087016fc5d https://hg.mozilla.org/integration/mozilla-inbound/rev/b411e5efa6cf
Assignee | ||
Comment 20•9 years ago
|
||
Apparently I forgot to land the last 2 patches. I'll do that later after a Try push.
Keywords: leave-open
https://hg.mozilla.org/mozilla-central/rev/9f00f5621fca https://hg.mozilla.org/mozilla-central/rev/d35a4a640099 https://hg.mozilla.org/mozilla-central/rev/ca1f72e930c4 https://hg.mozilla.org/mozilla-central/rev/f6087016fc5d https://hg.mozilla.org/mozilla-central/rev/b411e5efa6cf
Assignee | ||
Updated•9 years ago
|
Keywords: leave-open
Comment 22•9 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/499a2fece05b https://hg.mozilla.org/integration/mozilla-inbound/rev/dcb8086b1ffa
Comment 23•9 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/499a2fece05b https://hg.mozilla.org/mozilla-central/rev/dcb8086b1ffa
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
status-firefox45:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla45
Comment 24•9 years ago
|
||
bugherder uplift |
https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/499a2fece05b https://hg.mozilla.org/releases/mozilla-b2g44_v2_5/rev/dcb8086b1ffa
status-b2g-v2.5:
--- → fixed
Comment 25•9 years ago
|
||
removing the b2g 2.5 flag since this commit has been reverted due to an incorrect merge, sorry for the confusion
status-b2g-v2.5:
fixed → ---
You need to log in
before you can comment on or make changes to this bug.
Description
•