[llvm] f8e2e70 - [CGData] Return ArrayRef<std::string> in getNames (NFC) (#140675)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 20 00:03:52 PDT 2025
Author: Kazu Hirata
Date: 2025-05-20T00:03:48-07:00
New Revision: f8e2e709f079f5aafc9d8cd67ee9401910d43fc1
URL: https://github.com/llvm/llvm-project/commit/f8e2e709f079f5aafc9d8cd67ee9401910d43fc1
DIFF: https://github.com/llvm/llvm-project/commit/f8e2e709f079f5aafc9d8cd67ee9401910d43fc1.diff
LOG: [CGData] Return ArrayRef<std::string> in getNames (NFC) (#140675)
All uses of getNames is read access to the list of names, so we can
just return ArrayRef<std::string>. There is no need to make a copy as
we prepare a return value.
---------
Co-authored-by: Matt Arsenault <arsenm2 at gmail.com>
Added:
Modified:
llvm/include/llvm/CGData/StableFunctionMap.h
llvm/lib/CGData/StableFunctionMapRecord.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/CGData/StableFunctionMap.h b/llvm/include/llvm/CGData/StableFunctionMap.h
index 8881adf5889d0..a3a85b92c3b30 100644
--- a/llvm/include/llvm/CGData/StableFunctionMap.h
+++ b/llvm/include/llvm/CGData/StableFunctionMap.h
@@ -78,7 +78,7 @@ struct StableFunctionMap {
const HashFuncsMapType &getFunctionMap() const { return HashToFuncs; }
/// Get the NameToId vector for serialization.
- const SmallVector<std::string> getNames() const { return IdToName; }
+ ArrayRef<std::string> getNames() const { return IdToName; }
/// Get an existing ID associated with the given name or create a new ID if it
/// doesn't exist.
diff --git a/llvm/lib/CGData/StableFunctionMapRecord.cpp b/llvm/lib/CGData/StableFunctionMapRecord.cpp
index e23b0e072c9a3..537793b9e2b45 100644
--- a/llvm/lib/CGData/StableFunctionMapRecord.cpp
+++ b/llvm/lib/CGData/StableFunctionMapRecord.cpp
@@ -86,7 +86,7 @@ void StableFunctionMapRecord::serialize(raw_ostream &OS,
support::endian::Writer Writer(OS, endianness::little);
// Write Names.
- auto &Names = FunctionMap->getNames();
+ ArrayRef<std::string> Names = FunctionMap->getNames();
uint32_t ByteSize = 4;
Writer.write<uint32_t>(Names.size());
for (auto &Name : Names) {
More information about the llvm-commits
mailing list