Bug 1319626 - Part 1: Add new nsTArray append method for mozilla::Array. r=froydnj
authorMatt Woodrow <mwoodrow@mozilla.com>
Thu, 24 Nov 2016 18:11:30 +1300
changeset 324273 031a280d9c9c27ff2b61e506564733286e9201e9
parent 324272 8c6411235af992640066af2086363c92e5344eb3
child 324274 a279aabaa49082bfcd2dcc67285d2b265b1675d7
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewersfroydnj
bugs1319626
milestone53.0a1
Bug 1319626 - Part 1: Add new nsTArray append method for mozilla::Array. r=froydnj
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);