If you think a bug might affect users in the 57 release, please set the correct tracking and status flags for Release Management.

don't use QueryInterface when the compiler can do the cast for us

RESOLVED FIXED in Firefox 39

Status

()

Core
General
RESOLVED FIXED
3 years ago
3 years ago

People

(Reporter: froydnj, Assigned: froydnj)

Tracking

unspecified
mozilla39
Points:
---
Bug Flags:
in-testsuite -

Firefox Tracking Flags

(firefox39 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

3 years ago
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

3 years ago
Created attachment 8576654 [details] [diff] [review]
don't use QueryInterface when the compiler can do the cast for us
Attachment #8576654 - Flags: review?(ehsan)
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

3 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

3 years ago
https://hg.mozilla.org/integration/mozilla-inbound/rev/27533222749d
Flags: in-testsuite-
https://hg.mozilla.org/mozilla-central/rev/27533222749d
Status: NEW → RESOLVED
Last Resolved: 3 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.