Bug 1360137 - Part 1. Use LowerCaseEqualsLiteral instead of ToLowerCase. r?masayuki
From profiling TextEditor::OutputToString, most of WillOutputText is ToLowerCase. So, we should use LowerCaseEqualsLiteral instead. It can reduce string copy.
MozReview-Commit-ID: LwqZtxIJTbW
--- a/editor/libeditor/TextEditRules.cpp
+++ b/editor/libeditor/TextEditRules.cpp
@@ -1061,19 +1061,17 @@ TextEditRules::WillOutputText(Selection*
if (!aOutString || !aOutputFormat || !aCancel || !aHandled) {
return NS_ERROR_NULL_POINTER;
}
// initialize out param
*aCancel = false;
*aHandled = false;
- nsAutoString outputFormat(*aOutputFormat);
- ToLowerCase(outputFormat);
- if (outputFormat.EqualsLiteral("text/plain")) {
+ if (aOutputFormat->LowerCaseEqualsLiteral("text/plain")) {
// Only use these rules for plain text output.
if (IsPasswordEditor()) {
*aOutString = mPasswordText;
*aHandled = true;
} else if (mBogusNode) {
// This means there's no content, so output null string.
aOutString->Truncate();
*aHandled = true;