Skip to content

Commit 64ce9b0

Browse files
committed
RemoteMirror: Don't store StringRefs to temporary std::strings
1 parent b6e3f2a commit 64ce9b0

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

include/swift/RemoteInspection/TypeRef.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -364,10 +364,10 @@ class BoundGenericTypeRef final : public TypeRef, public NominalTypeTrait {
364364
class TupleTypeRef final : public TypeRef {
365365
protected:
366366
std::vector<const TypeRef *> Elements;
367-
std::vector<StringRef> Labels;
367+
std::vector<std::string> Labels;
368368

369369
static TypeRefID Profile(const std::vector<const TypeRef *> &Elements,
370-
const std::vector<StringRef> &Labels) {
370+
const std::vector<std::string> &Labels) {
371371
TypeRefID ID;
372372
for (auto Element : Elements)
373373
ID.addPointer(Element);
@@ -378,20 +378,20 @@ class TupleTypeRef final : public TypeRef {
378378

379379
public:
380380
TupleTypeRef(std::vector<const TypeRef *> Elements,
381-
std::vector<StringRef> Labels)
381+
std::vector<std::string> Labels)
382382
: TypeRef(TypeRefKind::Tuple), Elements(std::move(Elements)),
383383
Labels(std::move(Labels)) {}
384384

385385
template <typename Allocator>
386386
static const TupleTypeRef *create(Allocator &A,
387387
std::vector<const TypeRef *> Elements,
388-
const std::vector<StringRef> Labels) {
388+
const std::vector<std::string> Labels) {
389389
FIND_OR_CREATE_TYPEREF(A, TupleTypeRef, Elements, Labels);
390390
}
391391

392392
const std::vector<const TypeRef *> &getElements() const { return Elements; };
393393

394-
const std::vector<llvm::StringRef> &getLabels() const { return Labels; }
394+
const std::vector<std::string> &getLabels() const { return Labels; }
395395

396396
static bool classof(const TypeRef *TR) {
397397
return TR->getKind() == TypeRefKind::Tuple;

include/swift/RemoteInspection/TypeRefBuilder.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,8 @@ class TypeRefBuilder {
744744

745745
const TupleTypeRef *createTupleType(llvm::ArrayRef<const TypeRef *> elements,
746746
llvm::ArrayRef<StringRef> labels) {
747-
return TupleTypeRef::create(*this, elements, labels);
747+
std::vector<std::string> labelsVec(labels.begin(), labels.end());
748+
return TupleTypeRef::create(*this, elements, labelsVec);
748749
}
749750

750751
const TypeRef *createPackType(llvm::ArrayRef<const TypeRef *> elements) {

stdlib/public/RemoteInspection/TypeRef.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class PrintTypeRef : public TypeRefVisitor<PrintTypeRef, void> {
116116
for (auto NameElement : llvm::zip_first(Labels, T->getElements())) {
117117
auto Label = std::get<0>(NameElement);
118118
if (!Label.empty())
119-
stream << Label.str() << " = ";
119+
stream << Label << " = ";
120120
printRec(std::get<1>(NameElement));
121121
}
122122
stream << ")";

0 commit comments

Comments
 (0)