Closed
Bug 1039521
Opened 11 years ago
Closed 11 years ago
nsTArray: Add an AppendElement take taking a r-value reference
Categories
(Core :: XPCOM, defect)
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: jrmuizel, Assigned: jrmuizel)
References
Details
Attachments
(1 file, 1 obsolete file)
|
2.92 KB,
patch
|
froydnj
:
review+
|
Details | Diff | Splinter Review |
Here's a patch that implements this. I wasn't able to get
nsTArrayElementTraits<...>::Construct(iter, mozilla::Move(aItem));
to work so I just manually construct it. What's the correct way to do this?
Attachment #8456885 -
Flags: feedback?(trev.saunders)
Comment 1•11 years ago
|
||
khuey wrote a patch for this in bug 982212, but at least part of it foundered on the rocks of gcc 4.4. Does your patch do better there?
| Assignee | ||
Comment 2•11 years ago
|
||
| Assignee | ||
Comment 3•11 years ago
|
||
| Assignee | ||
Comment 4•11 years ago
|
||
This builds on all platforms on try.
Attachment #8456885 -
Attachment is obsolete: true
Attachment #8456885 -
Flags: feedback?(trev.saunders)
Attachment #8459698 -
Flags: review?(nfroyd)
Comment 5•11 years ago
|
||
Comment on attachment 8459698 [details] [diff] [review]
nsTArray: Add an AppendElement take taking a r-value reference
Review of attachment 8459698 [details] [diff] [review]:
-----------------------------------------------------------------
r=me with the change below.
::: xpcom/glue/nsTArray.h
@@ +1255,5 @@
> return AppendElements(&aItem, 1);
> }
>
> + // A variation on the AppendElements method defined above.
> + elem_type* AppendElement(elem_type&& aItem)
Seems like this should be templated over |class Item| like all the other AppendElement methods.
@@ +1262,5 @@
> + sizeof(elem_type))))
> + return nullptr;
> + index_type len = Length();
> + elem_type* iter = Elements() + len;
> + nsTArrayElementTraits<elem_type>::Construct(iter, mozilla::Forward<elem_type>(aItem));
...and we'd Forward<Item> here.
Attachment #8459698 -
Flags: review?(nfroyd) → review+
Comment 6•11 years ago
|
||
Comment on attachment 8459698 [details] [diff] [review]
nsTArray: Add an AppendElement take taking a r-value reference
Review of attachment 8459698 [details] [diff] [review]:
-----------------------------------------------------------------
::: xpcom/glue/nsTArray.h
@@ +1260,5 @@
> + {
> + if (!Alloc::Successful(this->EnsureCapacity(Length() + 1,
> + sizeof(elem_type))))
> + return nullptr;
> + index_type len = Length();
Seems a little odd to have this named here for a single use, but calling Length() in the EnsureCapacity call earlier.
| Assignee | ||
Comment 7•11 years ago
|
||
(In reply to Nathan Froyd (:froydnj) from comment #5)
> Comment on attachment 8459698 [details] [diff] [review]
> nsTArray: Add an AppendElement take taking a r-value reference
>
> Review of attachment 8459698 [details] [diff] [review]:
> -----------------------------------------------------------------
>
> r=me with the change below.
>
> ::: xpcom/glue/nsTArray.h
> @@ +1255,5 @@
> > return AppendElements(&aItem, 1);
> > }
> >
> > + // A variation on the AppendElements method defined above.
> > + elem_type* AppendElement(elem_type&& aItem)
>
> Seems like this should be templated over |class Item| like all the other
> AppendElement methods.
It seems like the templating over class Item is to allow implicit conversions from things that convert to elem_type. Adding that templating causes the build to fail on some compilers like msvc and older gcc. I'm also not sure it makes sense to accept an r-value reference of something that we'd need to convert.
| Assignee | ||
Comment 8•11 years ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #7)
>
> It seems like the templating over class Item is to allow implicit
> conversions from things that convert to elem_type. Adding that templating
> causes the build to fail on some compilers like msvc and older gcc. I'm also
> not sure it makes sense to accept an r-value reference of something that
> we'd need to convert.
You can see the compiler problems here with an older version:
https://tbpl.mozilla.org/?tree=Try&rev=0ac136ca5cc5
Comment 9•11 years ago
|
||
(In reply to Jeff Muizelaar [:jrmuizel] from comment #7)
> It seems like the templating over class Item is to allow implicit
> conversions from things that convert to elem_type. Adding that templating
> causes the build to fail on some compilers like msvc and older gcc. I'm also
> not sure it makes sense to accept an r-value reference of something that
> we'd need to convert.
OK, then. Patch without templating is fine.
Assignee: nobody → jmuizelaar
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
You need to log in
before you can comment on or make changes to this bug.
Description
•