Skip to content

Commit f8e2e70

Browse files
[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 <[email protected]>
1 parent 0baacd1 commit f8e2e70

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

llvm/include/llvm/CGData/StableFunctionMap.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ struct StableFunctionMap {
7878
const HashFuncsMapType &getFunctionMap() const { return HashToFuncs; }
7979

8080
/// Get the NameToId vector for serialization.
81-
const SmallVector<std::string> getNames() const { return IdToName; }
81+
ArrayRef<std::string> getNames() const { return IdToName; }
8282

8383
/// Get an existing ID associated with the given name or create a new ID if it
8484
/// doesn't exist.

llvm/lib/CGData/StableFunctionMapRecord.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void StableFunctionMapRecord::serialize(raw_ostream &OS,
8686
support::endian::Writer Writer(OS, endianness::little);
8787

8888
// Write Names.
89-
auto &Names = FunctionMap->getNames();
89+
ArrayRef<std::string> Names = FunctionMap->getNames();
9090
uint32_t ByteSize = 4;
9191
Writer.write<uint32_t>(Names.size());
9292
for (auto &Name : Names) {

0 commit comments

Comments
 (0)