Closed Bug 952660 Opened 11 years ago Closed 11 years ago

Simplify control flow in nsXPCWrappedJS::GetNewOrUsed

Categories

(Core :: XPConnect, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla29

People

(Reporter: mccr8, Assigned: mccr8)

Details

Attachments

(8 files)

Lot of gotos in there.
try run: https://tbpl.mozilla.org/?tree=Try&rev=20caa5300e5e

The trickiest thing the goto in GetNewOrUsed does is release clazz in some cases,
so using a smart pointer will simplify things.
Attachment #8351197 - Flags: review?(bobbyholley+bmo)
Substitute in the tail of the function for each goto, then eliminate
the resulting branches where possible.
Attachment #8351199 - Flags: review?(bobbyholley+bmo)
FindInherited is only ever used after running Find, and the way the checks
are chained is a little weird.
Attachment #8351202 - Flags: review?(bobbyholley+bmo)
We check for root, then don't change root and check for !root, so this can just be
an else.
Attachment #8351203 - Flags: review?(bobbyholley+bmo)
A non-root wrapper has to be inserted into the list. There's only one place this is needed, but I
think it makes more sense like this.
Attachment #8351204 - Flags: review?(bobbyholley+bmo)
Comment on attachment 8351197 [details] [diff] [review]
part 1 - Use smart pointer for clazz in nsXPCWrappedJS::GetNewOrUsed.

Could you rename clazz to clasp while you're at it? Doing it in a followup patch is fine.
Attachment #8351197 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351198 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351199 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351200 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351201 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351202 - Flags: review?(bobbyholley+bmo) → review+
Attachment #8351203 - Flags: review?(bobbyholley+bmo) → review+
Comment on attachment 8351204 [details] [diff] [review]
part 8 - Insert non-root wrappers into the list in the constructor for nsXPCWrappedJS.

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

Nice.
Attachment #8351204 - Flags: review?(bobbyholley+bmo) → review+
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: