Bug 952840, part 1 - Eliminate goto in XPCWrappedNative::FindTearOff. r=bholley

This commit is contained in:
Andrew McCreight 2014-01-06 17:32:24 -08:00
parent 2dff4ccc3f
commit 243ffdd612

View File

@ -1496,7 +1496,9 @@ XPCWrappedNative::FindTearOff(XPCNativeInterface* aInterface,
rv = NS_ERROR_OUT_OF_MEMORY;
}
}
goto return_result;
if (pError)
*pError = rv;
return to;
}
if (!firstAvailable && to->IsAvailable())
firstAvailable = to;
@ -1506,18 +1508,13 @@ XPCWrappedNative::FindTearOff(XPCNativeInterface* aInterface,
to = firstAvailable;
if (!to) {
XPCWrappedNativeTearOffChunk* newChunk =
new XPCWrappedNativeTearOffChunk();
if (!newChunk) {
rv = NS_ERROR_OUT_OF_MEMORY;
goto return_result;
}
auto newChunk = new XPCWrappedNativeTearOffChunk();
lastChunk->mNextChunk = newChunk;
to = newChunk->mTearOffs;
}
{
// Scope keeps |tearoff| from leaking across the return_result: label
// Scope keeps |tearoff| from leaking across the rest of the function.
AutoMarkingWrappedNativeTearOffPtr tearoff(cx, to);
rv = InitTearOff(to, aInterface, needJSObject);
// During shutdown, we don't sweep tearoffs. So make sure to unmark
@ -1528,8 +1525,6 @@ XPCWrappedNative::FindTearOff(XPCNativeInterface* aInterface,
to = nullptr;
}
return_result:
if (pError)
*pError = rv;
return to;