зеркало из https://github.com/mozilla/gecko-dev.git
Fixing bug 245619. Don't bother serializing the result of JS execution when the caller doesn't care about the value. r+sr=brendan@mozilla.org
This commit is contained in:
Родитель
bbf3ecb573
Коммит
41f7ad6178
|
@ -665,7 +665,6 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
|||
// have one.
|
||||
NS_ASSERTION(principal, "principal required for document");
|
||||
|
||||
nsAutoString ret;
|
||||
nsCAutoString url;
|
||||
|
||||
if (aRequest->mURI) {
|
||||
|
@ -679,8 +678,8 @@ nsScriptLoader::EvaluateScript(nsScriptLoadRequest* aRequest,
|
|||
|
||||
PRBool isUndefined;
|
||||
context->EvaluateString(aScript, nsnull, principal, url.get(),
|
||||
aRequest->mLineNo, aRequest->mJSVersion,
|
||||
ret, &isUndefined);
|
||||
aRequest->mLineNo, aRequest->mJSVersion, nsnull,
|
||||
&isUndefined);
|
||||
|
||||
context->SetProcessingScriptTag(PR_FALSE);
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ public:
|
|||
* @param aURL the URL or filename for error messages
|
||||
* @param aLineNo the starting line number of the script for error messages
|
||||
* @param aVersion the script language version to use when executing
|
||||
* @param aRetValue the result of executing the script
|
||||
* @param aRetValue the result of executing the script, or null for no result
|
||||
* @param aIsUndefined true if the result of executing the script is the
|
||||
* undefined value
|
||||
*
|
||||
|
@ -92,7 +92,7 @@ public:
|
|||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
const char* aVersion,
|
||||
nsAString& aRetValue,
|
||||
nsAString *aRetValue,
|
||||
PRBool* aIsUndefined) = 0;
|
||||
|
||||
virtual nsresult EvaluateStringWithValue(const nsAString& aScript,
|
||||
|
|
|
@ -4993,11 +4993,10 @@ GlobalWindowImpl::RunTimeout(nsTimeoutImpl *aTimeout)
|
|||
NS_REINTERPRET_CAST(const PRUnichar *,
|
||||
::JS_GetStringChars(timeout->mExpr));
|
||||
|
||||
nsAutoString retval;
|
||||
PRBool is_undefined;
|
||||
mContext->EvaluateString(nsDependentString(script), mJSObject,
|
||||
timeout->mPrincipal, timeout->mFileName,
|
||||
timeout->mLineNo, timeout->mVersion, retval,
|
||||
timeout->mLineNo, timeout->mVersion, nsnull,
|
||||
&is_undefined);
|
||||
} else {
|
||||
PRInt64 lateness64;
|
||||
|
|
|
@ -746,8 +746,9 @@ nsJSContext::EvaluateStringWithValue(const nsAString& aScript,
|
|||
aLineNo,
|
||||
&val);
|
||||
|
||||
if (aVersion)
|
||||
if (aVersion) {
|
||||
::JS_SetVersion(mContext, oldVersion);
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
// Tell XPConnect about any pending exceptions. This is needed
|
||||
|
@ -838,12 +839,16 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
const char* aVersion,
|
||||
nsAString& aRetValue,
|
||||
nsAString *aRetValue,
|
||||
PRBool* aIsUndefined)
|
||||
{
|
||||
if (!mScriptsEnabled) {
|
||||
*aIsUndefined = PR_TRUE;
|
||||
aRetValue.Truncate();
|
||||
|
||||
if (aRetValue) {
|
||||
aRetValue->Truncate();
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -940,14 +945,16 @@ nsJSContext::EvaluateString(const nsAString& aScript,
|
|||
|
||||
// If all went well, convert val to a string (XXXbe unless undefined?).
|
||||
if (ok) {
|
||||
rv = JSValueToAString(mContext, val, &aRetValue, aIsUndefined);
|
||||
rv = JSValueToAString(mContext, val, aRetValue, aIsUndefined);
|
||||
}
|
||||
else {
|
||||
if (aIsUndefined) {
|
||||
*aIsUndefined = PR_TRUE;
|
||||
}
|
||||
|
||||
aRetValue.Truncate();
|
||||
if (aRetValue) {
|
||||
aRetValue->Truncate();
|
||||
}
|
||||
}
|
||||
|
||||
ScriptEvaluated(PR_TRUE);
|
||||
|
|
|
@ -64,7 +64,7 @@ public:
|
|||
const char *aURL,
|
||||
PRUint32 aLineNo,
|
||||
const char* aVersion,
|
||||
nsAString& aRetValue,
|
||||
nsAString *aRetValue,
|
||||
PRBool* aIsUndefined);
|
||||
virtual nsresult EvaluateStringWithValue(const nsAString& aScript,
|
||||
void *aScopeObject,
|
||||
|
|
|
@ -281,7 +281,7 @@ nsresult nsJSThunk::EvaluateScript(nsIChannel *aChannel)
|
|||
url.get(), // url
|
||||
1, // line no
|
||||
nsnull,
|
||||
result,
|
||||
&result,
|
||||
&bIsUndefined);
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
|
|
|
@ -274,7 +274,7 @@ mozXMLTermUtils::ExecuteScript(nsIDOMDocument* aDOMDocument,
|
|||
const char* URL = "";
|
||||
result = scriptContext->EvaluateString(aScript, (void *) nsnull,
|
||||
docPrincipal, URL, 0, nsnull,
|
||||
aOutput, &isUndefined);
|
||||
&aOutput, &isUndefined);
|
||||
|
||||
XMLT_LOG(mozXMLTermUtils::ExecuteScript,21,("result=0x%x,isUndefined=0x%x\n",
|
||||
result, isUndefined));
|
||||
|
|
Загрузка…
Ссылка в новой задаче