From 18b7a1fc2f2f29de729946f89a0c6a9be64370d8 Mon Sep 17 00:00:00 2001 From: Andrew McCreight Date: Tue, 9 Aug 2016 07:21:26 -0700 Subject: [PATCH] Bug 1293666 - Add initializer_list ctor to AutoTArray. r=froydnj MozReview-Commit-ID: 8ORBttWN2Rj --HG-- extra : rebase_source : 9ad6ae8aff9cbc81c773297d0bb2f7478fb3516e --- docshell/base/nsDocShell.cpp | 3 +-- dom/base/File.cpp | 3 +-- xpcom/glue/nsTArray.h | 6 ++++++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 739a46ab3d15..35a8937386fa 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -4452,8 +4452,7 @@ nsDocShell::RemoveFromSessionHistory() int32_t index = 0; sessionHistory->GetIndex(&index); - AutoTArray ids; - ids.AppendElement(mHistoryID); + AutoTArray ids({mHistoryID}); internalHistory->RemoveEntries(ids, index); return NS_OK; } diff --git a/dom/base/File.cpp b/dom/base/File.cpp index 576d3583a200..0685b0a5288e 100644 --- a/dom/base/File.cpp +++ b/dom/base/File.cpp @@ -255,8 +255,7 @@ Blob::ToFile() already_AddRefed Blob::ToFile(const nsAString& aName, ErrorResult& aRv) const { - AutoTArray, 1> blobImpls; - blobImpls.AppendElement(mImpl); + AutoTArray, 1> blobImpls({mImpl}); nsAutoString contentType; mImpl->GetType(contentType); diff --git a/xpcom/glue/nsTArray.h b/xpcom/glue/nsTArray.h index e01778fcbf39..d48dd30815a1 100644 --- a/xpcom/glue/nsTArray.h +++ b/xpcom/glue/nsTArray.h @@ -2216,6 +2216,12 @@ public: this->SwapElements(aOther); } + MOZ_IMPLICIT AutoTArray(std::initializer_list aIL) + { + Init(); + this->AppendElements(aIL.begin(), aIL.size()); + } + self_type& operator=(const self_type& aOther) { base_type::operator=(aOther);