зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1402041 - Move most of the GetSingleton() body to a separate function to make the inline size smaller. r=kats
This commit is contained in:
Родитель
7404b3ac92
Коммит
c9eb43789d
|
@ -20,6 +20,17 @@ nsTArray<gfxPrefs::Pref*>* gfxPrefs::sGfxPrefList = nullptr;
|
|||
gfxPrefs* gfxPrefs::sInstance = nullptr;
|
||||
bool gfxPrefs::sInstanceHasBeenDestroyed = false;
|
||||
|
||||
gfxPrefs&
|
||||
gfxPrefs::CreateAndInitializeSingleton() {
|
||||
MOZ_ASSERT(!sInstanceHasBeenDestroyed,
|
||||
"Should never recreate a gfxPrefs instance!");
|
||||
sGfxPrefList = new nsTArray<Pref*>();
|
||||
sInstance = new gfxPrefs;
|
||||
sInstance->Init();
|
||||
MOZ_ASSERT(SingletonExists());
|
||||
return *sInstance;
|
||||
}
|
||||
|
||||
void
|
||||
gfxPrefs::DestroySingleton()
|
||||
{
|
||||
|
|
|
@ -763,19 +763,14 @@ public:
|
|||
// Manage the singleton:
|
||||
static gfxPrefs& GetSingleton()
|
||||
{
|
||||
MOZ_ASSERT(!sInstanceHasBeenDestroyed, "Should never recreate a gfxPrefs instance!");
|
||||
if (!sInstance) {
|
||||
sGfxPrefList = new nsTArray<Pref*>();
|
||||
sInstance = new gfxPrefs;
|
||||
sInstance->Init();
|
||||
}
|
||||
MOZ_ASSERT(SingletonExists());
|
||||
return *sInstance;
|
||||
return sInstance ? *sInstance : CreateAndInitializeSingleton();
|
||||
}
|
||||
static void DestroySingleton();
|
||||
static bool SingletonExists();
|
||||
|
||||
private:
|
||||
static gfxPrefs& CreateAndInitializeSingleton();
|
||||
|
||||
static gfxPrefs* sInstance;
|
||||
static bool sInstanceHasBeenDestroyed;
|
||||
static nsTArray<Pref*>* sGfxPrefList;
|
||||
|
|
Загрузка…
Ссылка в новой задаче