From e6f2cf55d3002cef94c3578fa1605fb8d8524ae1 Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Fri, 3 May 2013 17:22:46 -0400 Subject: [PATCH] bug 860027 - lazily get the list of interfaces r=bholley --- js/xpconnect/src/XPCComponents.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/js/xpconnect/src/XPCComponents.cpp b/js/xpconnect/src/XPCComponents.cpp index 5f219048f0e..b1367ab98ab 100644 --- a/js/xpconnect/src/XPCComponents.cpp +++ b/js/xpconnect/src/XPCComponents.cpp @@ -218,7 +218,6 @@ nsXPCComponents_Interfaces::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) nsXPCComponents_Interfaces::nsXPCComponents_Interfaces() { - XPTInterfaceInfoManager::GetSingleton()->GetScriptableInterfaces(mInterfaces); } nsXPCComponents_Interfaces::~nsXPCComponents_Interfaces() @@ -259,6 +258,13 @@ nsXPCComponents_Interfaces::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_INIT: case JSENUMERATE_INIT_ALL: { + // Lazily init the list of interfaces when someone tries to + // enumerate them. + if (mInterfaces.IsEmpty()) { + XPTInterfaceInfoManager::GetSingleton()-> + GetScriptableInterfaces(mInterfaces); + } + *statep = JSVAL_ZERO; if (idp) *idp = INT_TO_JSID(mInterfaces.Length()); @@ -500,7 +506,6 @@ nsXPCComponents_InterfacesByID::GetClassIDNoAlloc(nsCID *aClassIDNoAlloc) nsXPCComponents_InterfacesByID::nsXPCComponents_InterfacesByID() { - XPTInterfaceInfoManager::GetSingleton()->GetScriptableInterfaces(mInterfaces); } nsXPCComponents_InterfacesByID::~nsXPCComponents_InterfacesByID() @@ -539,6 +544,13 @@ nsXPCComponents_InterfacesByID::NewEnumerate(nsIXPConnectWrappedNative *wrapper, case JSENUMERATE_INIT: case JSENUMERATE_INIT_ALL: { + // Lazily init the list of interfaces when someone tries to + // enumerate them. + if (mInterfaces.IsEmpty()) { + XPTInterfaceInfoManager::GetSingleton()-> + GetScriptableInterfaces(mInterfaces); + } + *statep = JSVAL_ZERO; if (idp) *idp = INT_TO_JSID(mInterfaces.Length());