Skip to content

Commit 53bc35a

Browse files
committed
[polly] Tidy uses of raw_string_ostream (NFC)
As specified in the docs, 1) raw_string_ostream is always unbuffered and 2) the underlying buffer may be used directly ( 65b1361 for further reference ) * Don't call raw_string_ostream::flush(), which is essentially a no-op. * Avoid unneeded calls to raw_string_ostream::str(), to avoid excess indirection.
1 parent 848cec1 commit 53bc35a

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

polly/lib/Analysis/ScopDetectionDiagnostic.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ template <typename T> std::string operator+(Twine LHS, const T &RHS) {
8989
std::string Buf;
9090
raw_string_ostream fmt(Buf);
9191
fmt << RHS;
92-
fmt.flush();
9392

9493
return LHS.concat(Buf).str();
9594
}
@@ -669,7 +668,7 @@ std::string ReportAlias::formatInvalidAlias(std::string Prefix,
669668

670669
OS << Suffix;
671670

672-
return OS.str();
671+
return Message;
673672
}
674673

675674
std::string ReportAlias::getRemarkName() const { return "Alias"; }

polly/lib/Analysis/ScopInfo.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -1818,11 +1818,9 @@ std::pair<std::string, std::string> Scop::getEntryExitStr() const {
18181818
raw_string_ostream EntryStr(EntryName);
18191819

18201820
R.getEntry()->printAsOperand(EntryStr, false);
1821-
EntryStr.str();
18221821

18231822
if (R.getExit()) {
18241823
R.getExit()->printAsOperand(ExitStr, false);
1825-
ExitStr.str();
18261824
} else
18271825
ExitName = "FunctionExit";
18281826

polly/lib/CodeGen/BlockGenerators.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,7 @@ static std::string getInstName(Value *Val) {
645645
std::string Result;
646646
raw_string_ostream OS(Result);
647647
Val->printAsOperand(OS, false);
648-
return OS.str();
648+
return Result;
649649
}
650650

651651
void BlockGenerator::generateBeginStmtTrace(ScopStmt &Stmt, LoopToScevMapT &LTS,

polly/lib/Exchange/JSONExporter.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ static json::Array exportArrays(const Scop &S) {
116116
}
117117
for (; i < SAI->getNumberOfDimensions(); i++) {
118118
SAI->getDimensionSize(i)->print(RawStringOstream);
119-
Sizes.push_back(RawStringOstream.str());
119+
Sizes.push_back(Buffer);
120120
Buffer.clear();
121121
}
122122
Array["sizes"] = std::move(Sizes);
123123
SAI->getElementType()->print(RawStringOstream);
124-
Array["type"] = RawStringOstream.str();
124+
Array["type"] = Buffer;
125125
Buffer.clear();
126126
Arrays.push_back(std::move(Array));
127127
}
@@ -575,14 +575,14 @@ static bool areArraysEqual(ScopArrayInfo *SAI, const json::Object &Array) {
575575
for (unsigned i = 1; i < Array.getArray("sizes")->size(); i++) {
576576
SAI->getDimensionSize(i)->print(RawStringOstream);
577577
const json::Array &SizesArray = *Array.getArray("sizes");
578-
if (RawStringOstream.str() != SizesArray[i].getAsString().value())
578+
if (Buffer != SizesArray[i].getAsString().value())
579579
return false;
580580
Buffer.clear();
581581
}
582582

583583
// Check if key 'type' differs from the current one or is not valid.
584584
SAI->getElementType()->print(RawStringOstream);
585-
if (RawStringOstream.str() != Array.getString("type").value()) {
585+
if (Buffer != Array.getString("type").value()) {
586586
errs() << "Array has not a valid type.\n";
587587
return false;
588588
}

0 commit comments

Comments
 (0)