Open Bug 1343946 Opened 3 years ago Updated 2 years ago

XPCJSRuntime::InitializeStrings is a little weird


(Core :: XPConnect, enhancement, P3)






(Reporter: mccr8, Unassigned)


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 If this bug is not an enhancement request or a bug not present in a supported release of Firefox, then it may be reopened.
Closed: 2 years ago
Resolution: --- → INACTIVE
Resolution: INACTIVE → ---
You need to log in before you can comment on or make changes to this bug.