Bug 1319626 - Part 1: Add new nsTArray append method for mozilla::Array. r?nfroyd draft
authorMatt Woodrow <mwoodrow@mozilla.com>
Wed, 23 Nov 2016 14:34:58 +1300
changeset 442688 2654b62c62d639f4175f6c13ea4d229c56351235
parent 442687 0bc2b8cbfa1e3c6587b4ecde437d6c7484cb94d3
child 442689 156a9209f2c190f01a0feea69e2204a7e8c284eb
push id36782
push usermwoodrow@mozilla.com
push dateWed, 23 Nov 2016 01:39:09 +0000
reviewersnfroyd
bugs1319626
milestone53.0a1
Bug 1319626 - Part 1: Add new nsTArray append method for mozilla::Array. r?nfroyd MozReview-Commit-ID: BUrCdFtFz3W
xpcom/glue/nsTArray.h
--- a/xpcom/glue/nsTArray.h
+++ b/xpcom/glue/nsTArray.h
@@ -1516,16 +1516,22 @@ public:
   // @param aArray    The elements to append to this array.
   // @param aArrayLen The number of elements to append to this array.
   // @return          A pointer to the new elements in the array, or null if
   //                  the operation failed due to insufficient memory.
 protected:
   template<class Item, typename ActualAlloc = Alloc>
   elem_type* AppendElements(const Item* aArray, size_type aArrayLen);
 
+  template<class Item, size_t Length, typename ActualAlloc = Alloc>
+  elem_type* AppendElements(const mozilla::Array<Item, Length>& aArray)
+  {
+    return AppendElements<Item, ActualAlloc>(&aArray[0], Length);
+  }
+
 public:
 
   template<class Item>
   /* MOZ_MUST_USE */
   elem_type* AppendElements(const Item* aArray, size_type aArrayLen,
                             const mozilla::fallible_t&)
   {
     return AppendElements<Item, FallibleAlloc>(aArray, aArrayLen);