зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1494127 - Fix trivial calls to do_QueryInterface that return an nsresult r=smaug
Calls to do_QueryInterface to a base class can be replaced by a static cast, which is faster. Differential Revision: https://phabricator.services.mozilla.com/D7224 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
f30ca495d1
Коммит
ea6021b769
|
@ -123,8 +123,7 @@ nsContentBlocker::Init()
|
|||
// The branch is not a copy of the prefservice, but a new object, because
|
||||
// it is a non-default branch. Adding obeservers to it will only work if
|
||||
// we make sure that the object doesn't die. So, keep a reference to it.
|
||||
mPrefBranchInternal = do_QueryInterface(prefBranch, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mPrefBranchInternal = prefBranch;
|
||||
|
||||
rv = mPrefBranchInternal->AddObserver("", this, true);
|
||||
PrefChanged(prefBranch, nullptr);
|
||||
|
|
|
@ -512,13 +512,9 @@ nsMozIconURI::SchemeIs(const char* aScheme, bool* aEquals)
|
|||
nsresult
|
||||
nsMozIconURI::Clone(nsIURI** result)
|
||||
{
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIURL> newIconURL;
|
||||
if (mIconURL) {
|
||||
newIconURL = do_QueryInterface(mIconURL, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
newIconURL = mIconURL;
|
||||
}
|
||||
|
||||
RefPtr<nsMozIconURI> uri = new nsMozIconURI();
|
||||
|
|
|
@ -1224,7 +1224,7 @@ XRE_XPCShellMain(int argc, char** argv, char** envp,
|
|||
nsCOMPtr<nsIFile> dir;
|
||||
rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(dir));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
appDir = do_QueryInterface(dir, &rv);
|
||||
appDir = dir;
|
||||
dirprovider.SetAppDir(appDir);
|
||||
}
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -51,8 +51,7 @@ nsresult nsZipDataStream::Init(nsZipWriter *aWriter,
|
|||
nullptr);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mOutput = do_QueryInterface(converter, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
mOutput = converter;
|
||||
}
|
||||
else {
|
||||
mHeader->mMethod = ZIP_METHOD_STORE;
|
||||
|
|
|
@ -85,8 +85,7 @@ nsStreamListenerTee::OnDataAvailable(nsIRequest *request,
|
|||
rv = mInputTee->SetSource(input);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
tee = do_QueryInterface(mInputTee, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
tee = mInputTee;
|
||||
}
|
||||
|
||||
return mListener->OnDataAvailable(request, context, tee, offset, count);
|
||||
|
|
|
@ -746,8 +746,9 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
|
|||
rv = NS_GetSpecialDirectory(NS_XPCOM_CURRENT_PROCESS_DIR,
|
||||
getter_AddRefs(directory));
|
||||
}
|
||||
if (directory)
|
||||
mDiskCacheParentDirectory = do_QueryInterface(directory, &rv);
|
||||
if (directory) {
|
||||
mDiskCacheParentDirectory = directory;
|
||||
}
|
||||
}
|
||||
if (mDiskCacheParentDirectory) {
|
||||
bool firstSmartSizeRun;
|
||||
|
@ -816,8 +817,9 @@ nsCacheProfilePrefObserver::ReadPrefs(nsIPrefBranch* branch)
|
|||
getter_AddRefs(directory));
|
||||
}
|
||||
#endif
|
||||
if (directory)
|
||||
mOfflineCacheParentDirectory = do_QueryInterface(directory, &rv);
|
||||
if (directory) {
|
||||
mOfflineCacheParentDirectory = directory;
|
||||
}
|
||||
}
|
||||
|
||||
// read memory cache device prefs
|
||||
|
|
|
@ -996,10 +996,7 @@ nsMultiMixedConv::SendData()
|
|||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsCOMPtr<nsIInputStream> inStream(do_QueryInterface(ss, &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
return mPartChannel->SendOnDataAvailable(mContext, inStream, offset, mRawDataLength);
|
||||
return mPartChannel->SendOnDataAvailable(mContext, ss, offset, mRawDataLength);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -499,18 +499,12 @@ nsStreamConverterService::AsyncConvertData(const char *aFromType,
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIStreamListener> chainListener(do_QueryInterface(converter, &rv));
|
||||
if (NS_FAILED(rv)) {
|
||||
delete converterChain;
|
||||
return rv;
|
||||
}
|
||||
|
||||
// the last iteration of this loop will result in finalListener
|
||||
// pointing to the converter that "starts" the conversion chain.
|
||||
// this converter's "from" type is the original "from" type. Prior
|
||||
// to the last iteration, finalListener will continuously be wedged
|
||||
// into the next listener in the chain, then be updated.
|
||||
finalListener = chainListener;
|
||||
finalListener = converter;
|
||||
}
|
||||
delete converterChain;
|
||||
// return the first listener in the chain.
|
||||
|
|
|
@ -139,11 +139,7 @@ nsWebBrowserFind::FindNext(bool* aResult)
|
|||
}
|
||||
|
||||
// remember where we started
|
||||
nsCOMPtr<nsIDocShellTreeItem> startingItem =
|
||||
do_QueryInterface(searchFrame->GetDocShell(), &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIDocShellTreeItem> startingItem = searchFrame->GetDocShell();
|
||||
|
||||
nsCOMPtr<nsIDocShellTreeItem> curItem;
|
||||
|
||||
|
|
|
@ -562,8 +562,7 @@ nsTypeAheadFind::FindItNow(nsIPresShell *aPresShell, bool aIsLinksOnly,
|
|||
nsresult rv = fm->GetFocusedWindow(getter_AddRefs(focusedWindow));
|
||||
if (NS_SUCCEEDED(rv) && focusedWindow) {
|
||||
auto* fwPI = nsPIDOMWindowOuter::From(focusedWindow);
|
||||
nsCOMPtr<nsIDocShellTreeItem> fwTreeItem
|
||||
(do_QueryInterface(fwPI->GetDocShell(), &rv));
|
||||
nsCOMPtr<nsIDocShellTreeItem> fwTreeItem(fwPI->GetDocShell());
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIDocShellTreeItem> fwRootTreeItem;
|
||||
rv = fwTreeItem->GetSameTypeRootTreeItem(getter_AddRefs(fwRootTreeItem));
|
||||
|
|
|
@ -175,8 +175,8 @@ GetFile(nsIFile* dir, const nsACString& name, nsCOMPtr<nsIFile>& result)
|
|||
if (NS_FAILED(rv))
|
||||
return false;
|
||||
|
||||
result = do_QueryInterface(file, &rv);
|
||||
return NS_SUCCEEDED(rv);
|
||||
result = file;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
|
|
@ -305,8 +305,8 @@ NS_IMETHODIMP nsBaseFilePicker::SetDisplayDirectory(nsIFile *aDirectory)
|
|||
nsresult rv = aDirectory->Clone(getter_AddRefs(directory));
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
mDisplayDirectory = do_QueryInterface(directory, &rv);
|
||||
return rv;
|
||||
mDisplayDirectory = directory;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// Get the display directory
|
||||
|
|
Загрузка…
Ссылка в новой задаче