Open Bug 1343946 Opened 3 years ago Updated 2 years ago

XPCJSRuntime::InitializeStrings is a little weird

Categories

(Core :: XPConnect, enhancement, P3)

enhancement

Tracking

()

REOPENED

People

(Reporter: mccr8, Unassigned)

Details

This method, currently called XPCJSContext::JSContextInitialized, seems to have originally been called from multiple places, but is now only called once at XPConnect startup.

Here's the only call site:

 if (!gSelf->mContext->JSContextInitialized(gSelf->mContext->Context()))

Notice that it passes in argument that is computed off the object itself! That's not needed.

The body of the method contains this check:

    // if it is our first context then we need to generate our string ids
    if (JSID_IS_VOID(mStrIDs[0])) {

However, we only ever call this once, so we should instead assert that mStrIDs[0] is void. (Also, the old-style macro here is probably not ideal.)

There's also this bit of code:

    // these jsids filled in later when we have a JSContext to work with.
    mStrIDs[0] = JSID_VOID;

Which seems a little weird. Maybe this InitializeStrings method could be called at the end of that method?

Also, it feels like setting mStrIDs could be set to VOID in the ctor. and also done for all of the fields and not just the first one.
Priority: -- → P3
Per policy at https://wiki.mozilla.org/Bug_Triage/Projects/Bug_Handling/Bug_Husbandry#Inactive_Bugs. If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → INACTIVE
Status: RESOLVED → REOPENED
Resolution: INACTIVE → ---
You need to log in before you can comment on or make changes to this bug.