Skip to content

Commit

Permalink
[NFC][Sema] Return underlying strings directly instead of OS.str()
Browse files Browse the repository at this point in the history
This avoids an unnecessary copy required by 'return OS.str()', allowing
instead for NRVO or implicit move. The .str() call (which flushes the
stream) is no longer required since 65b1361,
which made raw_string_ostream unbuffered by default.

Differential Revision: https://reviews.llvm.org/D115374
  • Loading branch information
kepler-5 committed Dec 10, 2021
1 parent 0cf6f7b commit 5276002
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Sema/CodeCompleteConsumer.cpp
Expand Up @@ -335,7 +335,7 @@ std::string CodeCompletionString::getAsString() const {
break;
}
}
return OS.str();
return Result;
}

const char *CodeCompletionString::getTypedText() const {
Expand Down Expand Up @@ -640,7 +640,7 @@ static std::string getOverloadAsString(const CodeCompletionString &CCS) {
break;
}
}
return OS.str();
return Result;
}

void PrintingCodeCompleteConsumer::ProcessOverloadCandidates(
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaAttr.cpp
Expand Up @@ -792,7 +792,7 @@ attrMatcherRuleListToString(ArrayRef<attr::SubjectMatchRule> Rules) {
OS << (I.index() == Rules.size() - 1 ? ", and " : ", ");
OS << "'" << attr::getSubjectMatchRuleSpelling(I.value()) << "'";
}
return OS.str();
return Result;
}

} // end anonymous namespace
Expand Down

0 comments on commit 5276002

Please sign in to comment.