зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1575343, part 1 - Avoid a gratuitous string copy by calling the nsAString overload of GetCallingLocation. r=smaug
The nsAString overload of GetCallingLocation directly converts the original source file name string into an nsAString. A number of callers that want the source file name in an nsAString are calling the nsACString overload of GetCallingLocation, then calling NS_ConvertUTF8toUTF16. This results in an extra intermediate copy of the original string data. Differential Revision: https://phabricator.services.mozilla.com/D42727 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
d6e4ed531f
Коммит
62bd52a17f
|
@ -3724,7 +3724,7 @@ nsresult nsContentUtils::ReportToConsoleByWindowID(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsAutoCString spec;
|
||||
nsAutoString spec;
|
||||
if (!aLineNumber && aLocationMode == eUSE_CALLING_LOCATION) {
|
||||
JSContext* cx = GetCurrentJSContext();
|
||||
if (cx) {
|
||||
|
@ -3737,11 +3737,10 @@ nsresult nsContentUtils::ReportToConsoleByWindowID(
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!spec.IsEmpty()) {
|
||||
rv =
|
||||
errorObject->InitWithWindowID(aErrorText,
|
||||
NS_ConvertUTF8toUTF16(spec), // file name
|
||||
aSourceLine, aLineNumber, aColumnNumber,
|
||||
aErrorFlags, aCategory, aInnerWindowID);
|
||||
rv = errorObject->InitWithWindowID(aErrorText,
|
||||
spec, // file name
|
||||
aSourceLine, aLineNumber, aColumnNumber,
|
||||
aErrorFlags, aCategory, aInnerWindowID);
|
||||
} else {
|
||||
rv = errorObject->InitWithSourceURI(aErrorText, aURI, aSourceLine,
|
||||
aLineNumber, aColumnNumber, aErrorFlags,
|
||||
|
|
|
@ -4003,7 +4003,7 @@ void DeprecationWarning(const GlobalObject& aGlobal,
|
|||
if (window && window->GetExtantDoc()) {
|
||||
window->GetExtantDoc()->WarnOnceAbout(aOperation);
|
||||
|
||||
nsAutoCString fileName;
|
||||
nsAutoString fileName;
|
||||
Nullable<uint32_t> lineNumber;
|
||||
Nullable<uint32_t> columnNumber;
|
||||
uint32_t line = 0;
|
||||
|
@ -4014,8 +4014,7 @@ void DeprecationWarning(const GlobalObject& aGlobal,
|
|||
columnNumber.SetValue(column);
|
||||
}
|
||||
|
||||
MaybeReportDeprecation(window, aOperation,
|
||||
NS_ConvertUTF8toUTF16(fileName), lineNumber,
|
||||
MaybeReportDeprecation(window, aOperation, fileName, lineNumber,
|
||||
columnNumber);
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ void WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID,
|
|||
return;
|
||||
}
|
||||
|
||||
nsAutoCString spec;
|
||||
nsAutoString spec;
|
||||
uint32_t aLineNumber, aColumnNumber;
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (cx) {
|
||||
|
@ -134,9 +134,9 @@ void WebAudioUtils::LogToDeveloperConsole(uint64_t aWindowID,
|
|||
return;
|
||||
}
|
||||
|
||||
errorObject->InitWithWindowID(
|
||||
result, NS_ConvertUTF8toUTF16(spec), EmptyString(), aLineNumber,
|
||||
aColumnNumber, nsIScriptError::warningFlag, "Web Audio", aWindowID);
|
||||
errorObject->InitWithWindowID(result, spec, EmptyString(), aLineNumber,
|
||||
aColumnNumber, nsIScriptError::warningFlag,
|
||||
"Web Audio", aWindowID);
|
||||
console->LogMessage(errorObject);
|
||||
}
|
||||
|
||||
|
|
|
@ -136,7 +136,7 @@ void FeaturePolicyUtils::ReportViolation(Document* aDocument,
|
|||
return;
|
||||
}
|
||||
|
||||
nsAutoCString fileName;
|
||||
nsAutoString fileName;
|
||||
Nullable<int32_t> lineNumber;
|
||||
Nullable<int32_t> columnNumber;
|
||||
uint32_t line = 0;
|
||||
|
@ -152,9 +152,9 @@ void FeaturePolicyUtils::ReportViolation(Document* aDocument,
|
|||
}
|
||||
|
||||
RefPtr<FeaturePolicyViolationReportBody> body =
|
||||
new FeaturePolicyViolationReportBody(
|
||||
window, aFeatureName, NS_ConvertUTF8toUTF16(fileName), lineNumber,
|
||||
columnNumber, NS_LITERAL_STRING("enforce"));
|
||||
new FeaturePolicyViolationReportBody(window, aFeatureName, fileName,
|
||||
lineNumber, columnNumber,
|
||||
NS_LITERAL_STRING("enforce"));
|
||||
|
||||
ReportingUtils::Report(window, nsGkAtoms::featurePolicyViolation,
|
||||
NS_LITERAL_STRING("default"),
|
||||
|
|
|
@ -213,7 +213,7 @@ bool nsCSPContext::permitsInternal(
|
|||
if (!aIsPreload && aSendViolationReports) {
|
||||
uint32_t lineNumber = 0;
|
||||
uint32_t columnNumber = 0;
|
||||
nsAutoCString spec;
|
||||
nsAutoString spec;
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (cx) {
|
||||
nsJSUtils::GetCallingLocation(cx, spec, &lineNumber, &columnNumber);
|
||||
|
@ -229,10 +229,10 @@ bool nsCSPContext::permitsInternal(
|
|||
null */
|
||||
violatedDirective, p, /* policy index */
|
||||
EmptyString(), /* no observer subject */
|
||||
NS_ConvertUTF8toUTF16(spec), /* source file */
|
||||
EmptyString(), /* no script sample */
|
||||
lineNumber, /* line number */
|
||||
columnNumber); /* column number */
|
||||
spec, /* source file */
|
||||
EmptyString(), /* no script sample */
|
||||
lineNumber, /* line number */
|
||||
columnNumber); /* column number */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче