From e72928762f4c1828d89fc169c654c7fc62760447 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 18:10:06 -0400 Subject: core: Don't construct instance of Core::System, just to access its live instance This would result in a lot of allocations and related object construction, just to toss it all away immediately after the call. These are definitely not intentional, and it was intended that all of these should have been accessing the static function GetInstance() through the name itself, not constructed instances. --- src/core/core.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 8335d502e3..7936c5b568 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -29,7 +29,7 @@ System::~System() = default; /// Runs a CPU core while the system is powered on static void RunCpuCore(std::shared_ptr cpu_state) { - while (Core::System().GetInstance().IsPoweredOn()) { + while (Core::System::GetInstance().IsPoweredOn()) { cpu_state->RunLoop(true); } } -- cgit v1.2.3 From 74185c108eeee0d8deb45c0855780434f8e4936d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Wed, 18 Jul 2018 18:15:16 -0400 Subject: core: Make System's default constructor private This makes it a compilation error to construct additional instances of the System class directly, preventing accidental wasteful constructions over and over. --- src/core/core.cpp | 2 ++ src/core/core.h | 2 ++ 2 files changed, 4 insertions(+) (limited to 'src/core/core.cpp') diff --git a/src/core/core.cpp b/src/core/core.cpp index 7936c5b568..ae3849a365 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -25,6 +25,8 @@ namespace Core { /*static*/ System System::s_instance; +System::System() = default; + System::~System() = default; /// Runs a CPU core while the system is powered on diff --git a/src/core/core.h b/src/core/core.h index f90f085ad1..c6f69f001d 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -168,6 +168,8 @@ public: } private: + System(); + /// Returns the currently running CPU core Cpu& CurrentCpuCore(); -- cgit v1.2.3