================
@@ -142,37 +142,48 @@ getCommentsBeforeLoc(ASTContext *Ctx, SourceLocation Loc)
{
return Comments;
}
-static bool isLikelyTypo(llvm::ArrayRef<ParmVarDecl *> Params,
- StringRef ArgName, unsigned ArgIndex) {
- const std::string ArgNameLowerStr = ArgName.lower();
- const StringRef ArgNameLower = ArgNameLowerStr;
+static llvm::SmallString<64> getLowercasedString(StringRef Name) {
+ llvm::SmallString<64> Result;
+ Result.reserve(Name.size());
+ for (const char C : Name)
+ Result.push_back(llvm::toLower(C));
+ return Result;
+}
----------------
vbvictor wrote:
Sorry for pushback, but
TBH, I'm not a fan of avoiding `std::string` at all cost because it brings more
temporary variables (like `CandidateLower`, `TargetNameLower`) and new
functions `getLowercasedString` which make code bigger thus harder to read. And
there may be no performance benefit to it.
If we are to avoid allocations, we should probably change `StringRef::lower` to
do only 1 allocation instead of current
```cpp
std::string StringRef::lower() const {
return std::string(map_iterator(begin(), toLower),
map_iterator(end(), toLower));
}
```
We can do
```cpp
std::string StringRef::lower() const {
std::string res;
res.reserve(this->size());
// fill via cycle or smth
}
```
https://github.com/llvm/llvm-project/pull/172521
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits