Closed
Bug 1142503
Opened 10 years ago
Closed 10 years ago
don't use QueryInterface when the compiler can do the cast for us
Categories
(Core :: General, defect)
Core
General
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: froydnj, Assigned: froydnj)
Details
Attachments
(1 file)
15.39 KB,
patch
|
ehsan.akhgari
:
review+
|
Details | Diff | Splinter Review |
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.
![]() |
Assignee | |
Comment 1•10 years ago
|
||
Attachment #8576654 -
Flags: review?(ehsan)
Comment 2•10 years ago
|
||
Comment on attachment 8576654 [details] [diff] [review]
don't use QueryInterface when the compiler can do the cast for us
Review of attachment 8576654 [details] [diff] [review]:
-----------------------------------------------------------------
Nice! How did you find these?
::: editor/txtsvc/nsTextServicesDocument.cpp
@@ +2000,5 @@
>
> NS_ENSURE_TRUE(bodyElement, NS_ERROR_FAILURE);
>
> + bodyElement.forget(aNode);
> + result = NS_OK;
result is already successful, not sure if you need to reset it here.
@@ +2015,5 @@
>
> NS_ENSURE_TRUE(docElement, NS_ERROR_FAILURE);
>
> + docElement.forget(aNode);
> + result = NS_OK;
Ditto.
::: embedding/components/commandhandler/nsCommandGroup.cpp
@@ +292,1 @@
> if (!groupsEnum) return NS_ERROR_OUT_OF_MEMORY;
Please remove this check while you're here.
@@ +306,1 @@
> if (!theGroupEnum) return NS_ERROR_OUT_OF_MEMORY;
This too.
Attachment #8576654 -
Flags: review?(ehsan) → review+
![]() |
Assignee | |
Comment 3•10 years ago
|
||
(In reply to :Ehsan Akhgari (not reading bugmail, needinfo? me!) from comment #2)
> Nice! How did you find these?
grep '->QueryInterface(NS_GET_IID'
I confess to not fixing the ones in rdf/ or in various test files.
![]() |
Assignee | |
Comment 4•10 years ago
|
||
Flags: in-testsuite-
Comment 5•10 years ago
|
||
Status: NEW → RESOLVED
Closed: 10 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
You need to log in
before you can comment on or make changes to this bug.
Description
•