[llvm] [ProfileData] Use lambdas instead of std::bind (NFC) (PR #146625)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 1 20:19:21 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-pgo
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
Lambdas are a lot shorter than std::bind here.
---
Full diff: https://github.com/llvm/llvm-project/pull/146625.diff
1 Files Affected:
- (modified) llvm/lib/ProfileData/InstrProf.cpp (+8-12)
``````````diff
diff --git a/llvm/lib/ProfileData/InstrProf.cpp b/llvm/lib/ProfileData/InstrProf.cpp
index 9a8b4cfc81f6a..bd3964ce127fd 100644
--- a/llvm/lib/ProfileData/InstrProf.cpp
+++ b/llvm/lib/ProfileData/InstrProf.cpp
@@ -617,28 +617,24 @@ Error readAndDecodeStrings(StringRef NameStrings,
}
Error InstrProfSymtab::create(StringRef NameStrings) {
- return readAndDecodeStrings(
- NameStrings,
- std::bind(&InstrProfSymtab::addFuncName, this, std::placeholders::_1));
+ return readAndDecodeStrings(NameStrings,
+ [&](StringRef S) { return addFuncName(S); });
}
Error InstrProfSymtab::create(StringRef FuncNameStrings,
StringRef VTableNameStrings) {
- if (Error E = readAndDecodeStrings(FuncNameStrings,
- std::bind(&InstrProfSymtab::addFuncName,
- this, std::placeholders::_1)))
+ if (Error E = readAndDecodeStrings(
+ FuncNameStrings, [&](StringRef S) { return addFuncName(S); }))
return E;
- return readAndDecodeStrings(
- VTableNameStrings,
- std::bind(&InstrProfSymtab::addVTableName, this, std::placeholders::_1));
+ return readAndDecodeStrings(VTableNameStrings,
+ [&](StringRef S) { return addVTableName(S); });
}
Error InstrProfSymtab::initVTableNamesFromCompressedStrings(
StringRef CompressedVTableStrings) {
- return readAndDecodeStrings(
- CompressedVTableStrings,
- std::bind(&InstrProfSymtab::addVTableName, this, std::placeholders::_1));
+ return readAndDecodeStrings(CompressedVTableStrings,
+ [&](StringRef S) { return addVTableName(S); });
}
StringRef InstrProfSymtab::getCanonicalName(StringRef PGOName) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/146625
More information about the llvm-commits
mailing list