Closed Bug 1217307 Opened 9 years ago Closed 9 years ago

Remove some unnecessary null checks in dom/

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla45
Tracking Status
firefox44 --- affected
firefox45 --- fixed

People

(Reporter: poiru, Assigned: poiru)

Details

Attachments

(4 files)

These patches have been gathering dust for a few months. I lost a bunch of hunks because I didn't feel like resolving so many conflicts, but this is better than nothing.
Attachment #8677267 - Flags: review?(n.nethercote)
Attachment #8677272 - Flags: review?(n.nethercote)
Attachment #8677273 - Flags: review?(n.nethercote)
Attachment #8677275 - Flags: review?(n.nethercote)
Attachment #8677267 - Flags: review?(n.nethercote) → review+
Comment on attachment 8677272 [details] [diff] [review]
Remove some unnecessary null checks in dom/xslt/

Review of attachment 8677272 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/xslt/xpath/txNodeSetAdaptor.cpp
@@ +25,5 @@
>  {
>      if (!mValue) {
>          mValue = new txNodeSet(nullptr);
>      }
> +    return NS_OK;

Bonus points if you change the return type of this function to |void| and avoid additional redundant checks up the call chain.

::: dom/xslt/xpath/txXPCOMExtensionFunction.cpp
@@ +255,5 @@
>  #ifdef TX_TO_STRING
>                                                    aName,
>  #endif
>                                                    aState);
> +    return NS_OK;

Ditto.

::: dom/xslt/xslt/txStylesheetCompiler.cpp
@@ +1086,5 @@
>      nsresult rv = findFunction(aName, aID, this, aFunction);
>      if (rv == NS_ERROR_XPATH_UNKNOWN_FUNCTION &&
>          (aID != kNameSpaceID_None || fcp())) {
>          *aFunction = new txErrorFunctionCall(aName);
> +        rv = NS_OK;

Ditto.

::: dom/xslt/xslt/txXSLTNumberCounters.cpp
@@ +97,5 @@
>          // if we don't recognize the token then use '1'
>          aCounter = new txDecimalCounter(1, aGroupSize, aGroupSeparator);
>      }
> +    MOZ_ASSERT(aCounter);
> +    return NS_OK;

Ditto.
Attachment #8677272 - Flags: review?(n.nethercote) → review+
Attachment #8677273 - Flags: review?(n.nethercote) → review+
Comment on attachment 8677275 [details] [diff] [review]
Remove some unnecessary null checks in rest of dom/

Review of attachment 8677275 [details] [diff] [review]:
-----------------------------------------------------------------

::: dom/plugins/base/nsPluginNativeWindow.cpp
@@ +40,5 @@
>  nsresult PLUG_NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
>  {
>    NS_ENSURE_ARG_POINTER(aPluginNativeWindow);
>    *aPluginNativeWindow = new nsPluginNativeWindowPLATFORM();
> +  return NS_OK;

Can you now change the return type of this function to |void|? Maybe; I haven't checked all the instances to see if any can return something other than NS_OK.
Attachment #8677275 - Flags: review?(n.nethercote) → review+
Nice changes. Thank you for persevering.
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: