зеркало из https://github.com/mozilla/gecko-dev.git
Bug 968520 - Add fallible variants of nsTArray::InsertElementsAt. r=froydnj
This commit is contained in:
Родитель
1f8d7454e3
Коммит
46db3a10bb
|
@ -1604,11 +1604,12 @@ public:
|
|||
// @param aIndex the place to insert the new elements. This must be no
|
||||
// greater than the current length of the array.
|
||||
// @param aCount the number of elements to insert
|
||||
template<typename ActualAlloc = Alloc>
|
||||
elem_type* InsertElementsAt(index_type aIndex, size_type aCount)
|
||||
{
|
||||
if (!base_type::template InsertSlotsAt<Alloc>(aIndex, aCount,
|
||||
sizeof(elem_type),
|
||||
MOZ_ALIGNOF(elem_type))) {
|
||||
if (!base_type::template InsertSlotsAt<ActualAlloc>(aIndex, aCount,
|
||||
sizeof(elem_type),
|
||||
MOZ_ALIGNOF(elem_type))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1622,6 +1623,13 @@ public:
|
|||
return Elements() + aIndex;
|
||||
}
|
||||
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
return InsertElementsAt<FallibleAlloc>(aIndex, aCount);
|
||||
}
|
||||
|
||||
// This method inserts elements into the array, constructing them
|
||||
// elem_type's copy constructor (or whatever one-arg constructor
|
||||
// happens to match the Item type).
|
||||
|
@ -1629,13 +1637,13 @@ public:
|
|||
// greater than the current length of the array.
|
||||
// @param aCount the number of elements to insert.
|
||||
// @param aItem the value to use when constructing the new elements.
|
||||
template<class Item>
|
||||
template<class Item, typename ActualAlloc = Alloc>
|
||||
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
|
||||
const Item& aItem)
|
||||
{
|
||||
if (!base_type::template InsertSlotsAt<Alloc>(aIndex, aCount,
|
||||
sizeof(elem_type),
|
||||
MOZ_ALIGNOF(elem_type))) {
|
||||
if (!base_type::template InsertSlotsAt<ActualAlloc>(aIndex, aCount,
|
||||
sizeof(elem_type),
|
||||
MOZ_ALIGNOF(elem_type))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -1649,6 +1657,14 @@ public:
|
|||
return Elements() + aIndex;
|
||||
}
|
||||
|
||||
template<class Item>
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
elem_type* InsertElementsAt(index_type aIndex, size_type aCount,
|
||||
const Item& aItem, const mozilla::fallible_t&)
|
||||
{
|
||||
return InsertElementsAt<Item, FallibleAlloc>(aIndex, aCount, aItem);
|
||||
}
|
||||
|
||||
// This method may be called to minimize the memory used by this array.
|
||||
void Compact()
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче