зеркало из https://github.com/mozilla/gecko-dev.git
bug 856696 - make nsTArray::SwapElements() return void r=jlebar
This commit is contained in:
Родитель
9c14887d75
Коммит
b81241eb2d
|
@ -300,7 +300,7 @@ nsTArray_base<Alloc>::IsAutoArrayRestorer::~IsAutoArrayRestorer() {
|
|||
|
||||
template<class Alloc>
|
||||
template<class Allocator>
|
||||
bool
|
||||
typename Alloc::ResultTypeProxy
|
||||
nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
|
||||
size_type elemSize,
|
||||
size_t elemAlign) {
|
||||
|
@ -321,14 +321,14 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
|
|||
|
||||
if (!EnsureNotUsingAutoArrayBuffer(elemSize) ||
|
||||
!other.EnsureNotUsingAutoArrayBuffer(elemSize)) {
|
||||
return false;
|
||||
return Alloc::FailureResult();
|
||||
}
|
||||
|
||||
Header *temp = mHdr;
|
||||
mHdr = other.mHdr;
|
||||
other.mHdr = temp;
|
||||
|
||||
return true;
|
||||
return Alloc::SuccessResult();
|
||||
}
|
||||
|
||||
// Swap the two arrays using memcpy, since at least one is using an auto
|
||||
|
@ -344,7 +344,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
|
|||
|
||||
if (!Alloc::Successful(EnsureCapacity(other.Length(), elemSize)) ||
|
||||
!Allocator::Successful(other.EnsureCapacity(Length(), elemSize))) {
|
||||
return false;
|
||||
return Alloc::FailureResult();
|
||||
}
|
||||
|
||||
// The EnsureCapacity calls above shouldn't have caused *both* arrays to
|
||||
|
@ -372,7 +372,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
|
|||
// could, in theory, allocate a huge AutoTArray on the heap.)
|
||||
nsAutoArrayBase<nsTArray_Impl<uint8_t, Alloc>, 64> temp;
|
||||
if (!Alloc::Successful(temp.EnsureCapacity(smallerLength, elemSize))) {
|
||||
return false;
|
||||
return Alloc::FailureResult();
|
||||
}
|
||||
|
||||
memcpy(temp.Elements(), smallerElements, smallerLength * elemSize);
|
||||
|
@ -387,7 +387,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
|
|||
mHdr->mLength = other.Length();
|
||||
other.mHdr->mLength = tempLength;
|
||||
|
||||
return true;
|
||||
return Alloc::SuccessResult();
|
||||
}
|
||||
|
||||
template<class Alloc>
|
||||
|
|
|
@ -424,9 +424,10 @@ protected:
|
|||
|
||||
protected:
|
||||
template<class Allocator>
|
||||
bool SwapArrayElements(nsTArray_base<Allocator>& other,
|
||||
size_type elemSize,
|
||||
size_t elemAlign);
|
||||
typename Alloc::ResultTypeProxy
|
||||
SwapArrayElements(nsTArray_base<Allocator>& other,
|
||||
size_type elemSize,
|
||||
size_t elemAlign);
|
||||
|
||||
// This is an RAII class used in SwapArrayElements.
|
||||
class IsAutoArrayRestorer {
|
||||
|
@ -1157,8 +1158,10 @@ public:
|
|||
// This method causes the elements contained in this array and the given
|
||||
// array to be swapped.
|
||||
template<class Allocator>
|
||||
bool SwapElements(nsTArray_Impl<E, Allocator>& other) {
|
||||
return this->SwapArrayElements(other, sizeof(elem_type), MOZ_ALIGNOF(elem_type));
|
||||
typename Alloc::ResultType
|
||||
SwapElements(nsTArray_Impl<E, Allocator>& other) {
|
||||
return Alloc::Result(this->SwapArrayElements(other, sizeof(elem_type),
|
||||
MOZ_ALIGNOF(elem_type)));
|
||||
}
|
||||
|
||||
//
|
||||
|
|
Загрузка…
Ссылка в новой задаче