r238466 - [Format] Skip creating temporary std::strings when filling another string.
Benjamin Kramer
benny.kra at googlemail.com
Thu May 28 12:55:49 PDT 2015
Author: d0k
Date: Thu May 28 14:55:49 2015
New Revision: 238466
URL: http://llvm.org/viewvc/llvm-project?rev=238466&view=rev
Log:
[Format] Skip creating temporary std::strings when filling another string.
No functional change intended.
Modified:
cfe/trunk/lib/Format/WhitespaceManager.cpp
Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=238466&r1=238465&r2=238466&view=diff
==============================================================================
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Thu May 28 14:55:49 2015
@@ -402,7 +402,7 @@ void WhitespaceManager::appendNewlineTex
unsigned Offset =
std::min<int>(EscapedNewlineColumn - 1, PreviousEndOfTokenColumn);
for (unsigned i = 0; i < Newlines; ++i) {
- Text.append(std::string(EscapedNewlineColumn - Offset - 1, ' '));
+ Text.append(EscapedNewlineColumn - Offset - 1, ' ');
Text.append(UseCRLF ? "\\\r\n" : "\\\n");
Offset = 0;
}
@@ -414,7 +414,7 @@ void WhitespaceManager::appendIndentText
unsigned WhitespaceStartColumn) {
switch (Style.UseTab) {
case FormatStyle::UT_Never:
- Text.append(std::string(Spaces, ' '));
+ Text.append(Spaces, ' ');
break;
case FormatStyle::UT_Always: {
unsigned FirstTabWidth =
@@ -424,8 +424,8 @@ void WhitespaceManager::appendIndentText
Spaces -= FirstTabWidth;
Text.append("\t");
}
- Text.append(std::string(Spaces / Style.TabWidth, '\t'));
- Text.append(std::string(Spaces % Style.TabWidth, ' '));
+ Text.append(Spaces / Style.TabWidth, '\t');
+ Text.append(Spaces % Style.TabWidth, ' ');
break;
}
case FormatStyle::UT_ForIndentation:
@@ -436,10 +436,10 @@ void WhitespaceManager::appendIndentText
if (Indentation > Spaces)
Indentation = Spaces;
unsigned Tabs = Indentation / Style.TabWidth;
- Text.append(std::string(Tabs, '\t'));
+ Text.append(Tabs, '\t');
Spaces -= Tabs * Style.TabWidth;
}
- Text.append(std::string(Spaces, ' '));
+ Text.append(Spaces, ' ');
break;
}
}
More information about the cfe-commits
mailing list