Skip to content

Commit

Permalink
STYLE: Let Singleton assume that SetGlobalInstance always returns true
Browse files Browse the repository at this point in the history
`SingletonIndex::SetGlobalInstance` always returns true, so it is not necessary
to handle the hypothetical case that it /might/ return false.
  • Loading branch information
N-Dekker committed Aug 19, 2023
1 parent 9da299b commit 6ec6328
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions Modules/Core/Common/include/itkSingleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,7 @@ Singleton(const char * globalName, std::function<void(void *)> func, std::functi
if (instance == nullptr)
{
instance = new T;
if (!SingletonIndex::GetInstance()->SetGlobalInstance<T>(globalName, instance, func, deleteFunc))
{
delete instance;
instance = nullptr;
}
SingletonIndex::GetInstance()->SetGlobalInstance<T>(globalName, instance, func, deleteFunc);
}
return instance;
}
Expand Down

0 comments on commit 6ec6328

Please sign in to comment.