Use sead::Buffer::fill where applicable

Equivalent, shorter, more readable, and matching!
This commit is contained in:
Léo Lam
2022-03-25 21:33:00 +01:00
parent 0e8cad1d0d
commit 4b2c55b82b
5 changed files with 5 additions and 11 deletions
@@ -18,7 +18,6 @@ AS::~AS() = default;
void AS::doCreate_(u8*, u32, sead::Heap*) {}
// NON_MATCHING: SafeString vtable load is reordered
bool AS::parse_(u8* data, size_t size, sead::Heap* parent_heap) {
mHeap = util::tryCreateDualHeap(parent_heap);
if (!mHeap)
@@ -47,8 +46,7 @@ bool AS::parse_(u8* data, size_t size, sead::Heap* parent_heap) {
return false;
}
for (int i = 0, n = mElementResources.size(); i < n; ++i)
mElementResources(i) = nullptr;
mElementResources.fill(nullptr);
ASResource::ParseArgs args;
args.list = {};
@@ -228,8 +228,7 @@ bool ASResourceWithChildren::doParse(const ASResource::ParseArgs& args) {
if (!mChildren.tryAllocBuffer(size, args.heap))
return false;
for (int i = 0, n = mChildren.size(); i < n; ++i)
mChildren(i) = nullptr;
mChildren.fill(nullptr);
for (auto it = mChildren.begin(), end = mChildren.end(); it != end; ++it) {
const auto idx = *Children.getParameterData<int>(it.getIndex());
@@ -259,8 +259,7 @@ bool ASExtensions::parse(const ASExtensions::ParseArgs& args) {
if (!mParsers.tryAllocBuffer(num_extensions, args.heap))
return false;
for (int i = 0, n = mParsers.size(); i < n; ++i)
mParsers(i) = nullptr;
mParsers.fill(nullptr);
auto it = mParsers.begin();
const auto end = mParsers.end();
@@ -22,9 +22,7 @@ public:
void alloc(int capacity, sead::Heap* heap) {
SEAD_ASSERT(sead::Mathi::isPow2(capacity));
mBuffer.allocBufferAssert(capacity, heap);
for (int i = 0, n = getCapacity(); i < n; ++i)
mBuffer(i) = nullptr;
mBuffer.fill(nullptr);
}
void freeBuffer() { mBuffer.freeBuffer(); }