Bug 1142503 - don't use QueryInterface when the compiler can do the cast for us; r=ehsan

Calling QueryInterface with a statically known IID should typically not
be necessary.  In those cases where it's not, the compiler can do the
cast for us, though we have to supply the reference-counting that
QueryInterface would do.

In passing, several redundant null-checks for the result of |new T| have
been deleted.
This commit is contained in:
Nathan Froyd
2015-03-12 09:43:50 -04:00
parent 6e971c203a
commit 26a0b56c7a
13 changed files with 43 additions and 48 deletions

View File

@@ -385,9 +385,7 @@ nsComposerCommandsUpdater::Notify(nsITimer *timer)
nsresult
NS_NewComposerCommandsUpdater(nsISelectionListener** aInstancePtrResult)
{
nsComposerCommandsUpdater* newThang = new nsComposerCommandsUpdater;
NS_ENSURE_TRUE(newThang, NS_ERROR_OUT_OF_MEMORY);
return newThang->QueryInterface(NS_GET_IID(nsISelectionListener),
(void **)aInstancePtrResult);
nsRefPtr<nsComposerCommandsUpdater> newThang = new nsComposerCommandsUpdater;
newThang.forget(aInstancePtrResult);
return NS_OK;
}