Closed Bug 983989 Opened 10 years ago Closed 10 years ago

Cleanup XPCConvert::NativeData2JS

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla31

People

(Reporter: Ms2ger, Assigned: Ms2ger)

Details

Attachments

(3 files)

The structure of XPCConvert::NativeData2JS is basically

switch (type.TagPart()) {
  // some cases
  default: {
    switch (type.TagPart()) {
      // some more cases
    }
  }
}

This is kinda silly.
Attached patch Part a: ReindentSplinter Review
This makes the indentation of cases consistent, and reindents the nested switch to make the next patch easier to review.
Attachment #8391702 - Flags: review?(bobbyholley)
This drops the nested switch and makes sure we return from all cases, rather than breaking to the "return true;" at the end of the function.
Attachment #8391703 - Flags: review?(bobbyholley)
Attached patch Part c: CleanupSplinter Review
Removed the C-style casts that were silently casting away constness too, and moved some assignments out of if conditions.
Attachment #8391704 - Flags: review?(bobbyholley)
Comment on attachment 8391702 [details] [diff] [review]
Part a: Reindent

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

rs=bholley assuming that this is only whitespace change.
Attachment #8391702 - Flags: review?(bobbyholley) → review+
Comment on attachment 8391703 [details] [diff] [review]
Part b: Simplify code flow

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

<3,r=bholley

::: js/xpconnect/src/XPCConvert.cpp
@@ +340,5 @@
>  
> +            return XPCVariant::VariantDataToJS(variant,
> +                                               pErr, d);
> +        }
> +        // else...

I think this comment can go.

@@ +355,1 @@
>  #endif

I have no idea what this DEBUG block is trying to check. Can you remove it while you're there?
Attachment #8391703 - Flags: review?(bobbyholley) → review+
Comment on attachment 8391704 [details] [diff] [review]
Part c: Cleanup

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

::: js/xpconnect/src/XPCConvert.cpp
@@ +341,5 @@
>  
>              return XPCVariant::VariantDataToJS(variant,
>                                                 pErr, d);
>          }
> +

Ah ok, you removed this here.
Attachment #8391704 - Flags: review?(bobbyholley) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: