mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 968520 - Add fallible variant of nsTArray::SetLength. r=froydnj
This commit is contained in:
parent
5b2cdf2452
commit
a0cd263bb6
@ -1557,16 +1557,23 @@ public:
|
||||
// @return True if the operation succeeded; false otherwise.
|
||||
// See also TruncateLength if the new length is guaranteed to be smaller than
|
||||
// the old.
|
||||
typename Alloc::ResultType SetLength(size_type aNewLen)
|
||||
template<typename ActualAlloc = Alloc>
|
||||
typename ActualAlloc::ResultType SetLength(size_type aNewLen)
|
||||
{
|
||||
size_type oldLen = Length();
|
||||
if (aNewLen > oldLen) {
|
||||
return Alloc::ConvertBoolToResultType(
|
||||
InsertElementsAt(oldLen, aNewLen - oldLen) != nullptr);
|
||||
return ActualAlloc::ConvertBoolToResultType(
|
||||
InsertElementsAt<ActualAlloc>(oldLen, aNewLen - oldLen) != nullptr);
|
||||
}
|
||||
|
||||
TruncateLength(aNewLen);
|
||||
return Alloc::ConvertBoolToResultType(true);
|
||||
return ActualAlloc::ConvertBoolToResultType(true);
|
||||
}
|
||||
|
||||
/* MOZ_WARN_UNUSED_RESULT */
|
||||
bool SetLength(size_type aNewLen, const mozilla::fallible_t&)
|
||||
{
|
||||
return SetLength<FallibleAlloc>(aNewLen);
|
||||
}
|
||||
|
||||
// This method modifies the length of the array, but may only be
|
||||
|
Loading…
Reference in New Issue
Block a user