citra-emu
/
citra
Archived
1
0
Fork 0

core/memory: Remove unnecessary memory zeroing in MemorySystem::Impl

std::make_unique for arrays is equivalent to doing:

std::unique_ptr<T>(new typename std::remove_extent<T>::type[size]())

(note the ending () after the array size specifier). This means that the
default value within memory for the constructed types will be whatever
the default constructor for that type does. Given the built-in
type for std::uint8_t doesn't have a constructor, this is equivalent to
forcing zero-initialization, so the memory will already be zeroed out on
construction. Because of that, there's no need to zero it out again.
This commit is contained in:
Lioncash 2018-12-27 00:35:35 -05:00
parent 096e2a7ceb
commit 432e847c24
1 changed files with 0 additions and 6 deletions

View File

@ -56,12 +56,6 @@ private:
class MemorySystem::Impl {
public:
Impl() {
std::fill(fcram.get(), fcram.get() + Memory::FCRAM_N3DS_SIZE, 0);
std::fill(vram.get(), vram.get() + Memory::VRAM_SIZE, 0);
std::fill(n3ds_extra_ram.get(), n3ds_extra_ram.get() + Memory::N3DS_EXTRA_RAM_SIZE, 0);
}
// Visual Studio would try to allocate these on compile time if they are std::array, which would
// exceed the memory limit.
std::unique_ptr<u8[]> fcram = std::make_unique<u8[]>(Memory::FCRAM_N3DS_SIZE);