Bug 1163916 (part 1) - Avoid a static nsDebugImpl constructor. r=froydnj.

This commit is contained in:
Nicholas Nethercote 2015-05-13 16:47:55 -07:00
parent 5142eb7562
commit 742d99332f
2 changed files with 8 additions and 6 deletions

View File

@ -579,16 +579,20 @@ Break(const char* aMsg)
#endif
}
static const nsDebugImpl kImpl;
nsresult
nsDebugImpl::Create(nsISupports* aOuter, const nsIID& aIID, void** aInstancePtr)
{
static const nsDebugImpl* sImpl;
if (NS_WARN_IF(aOuter)) {
return NS_ERROR_NO_AGGREGATION;
}
return const_cast<nsDebugImpl*>(&kImpl)->QueryInterface(aIID, aInstancePtr);
if (!sImpl) {
sImpl = new nsDebugImpl();
}
return const_cast<nsDebugImpl*>(sImpl)->QueryInterface(aIID, aInstancePtr);
}
////////////////////////////////////////////////////////////////////////////////

View File

@ -12,9 +12,7 @@
class nsDebugImpl : public nsIDebug2
{
public:
nsDebugImpl()
{
}
nsDebugImpl() = default;
NS_DECL_ISUPPORTS
NS_DECL_NSIDEBUG2