Skip to content

Commit

Permalink
refactor: make getInstance more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
OEOTYAN committed Mar 29, 2024
1 parent a6ec7ef commit d34cd47
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/plugin/MyPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

namespace my_plugin {

std::unique_ptr<MyPlugin>& MyPlugin::getInstance() {
static std::unique_ptr<MyPlugin> instance;
return instance;
static std::unique_ptr<MyPlugin> instance;

MyPlugin& MyPlugin::getInstance() {
return *instance;
}

bool MyPlugin::load() {
Expand All @@ -32,4 +33,4 @@ bool MyPlugin::disable() {

} // namespace my_plugin

LL_REGISTER_PLUGIN(my_plugin::MyPlugin, my_plugin::MyPlugin::getInstance());
LL_REGISTER_PLUGIN(my_plugin::MyPlugin, my_plugin::instance);
2 changes: 1 addition & 1 deletion src/plugin/MyPlugin.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace my_plugin {
class MyPlugin {

public:
static std::unique_ptr<MyPlugin>& getInstance();
static MyPlugin& getInstance();

MyPlugin(ll::plugin::NativePlugin& self) : mSelf(self) {}

Expand Down

0 comments on commit d34cd47

Please sign in to comment.