From 432e847c24b8c33465c19a53f779b98e093961f9 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Thu, 27 Dec 2018 00:35:35 -0500 Subject: [PATCH] core/memory: Remove unnecessary memory zeroing in MemorySystem::Impl std::make_unique for arrays is equivalent to doing: std::unique_ptr(new typename std::remove_extent::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. --- src/core/memory.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/core/memory.cpp b/src/core/memory.cpp index 7693cdd9b..7080b30dc 100644 --- a/src/core/memory.cpp +++ b/src/core/memory.cpp @@ -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 fcram = std::make_unique(Memory::FCRAM_N3DS_SIZE);