[Edit] Use StringRef's copy method. No functional change intended.

llvm-svn: 243968
This commit is contained in:
Benjamin Kramer 2015-08-04 11:18:09 +00:00
parent e2453afff6
commit 323dc2d064
3 changed files with 2 additions and 12 deletions

View File

@ -134,12 +134,6 @@ private:
SourceLocation *MacroBegin = nullptr) const;
bool isAtEndOfMacroExpansion(SourceLocation loc,
SourceLocation *MacroEnd = nullptr) const;
StringRef copyString(StringRef str) {
char *buf = StrAlloc.Allocate<char>(str.size());
std::memcpy(buf, str.data(), str.size());
return StringRef(buf, str.size());
}
};
}

View File

@ -62,11 +62,7 @@ public:
void applyRewrites(EditsReceiver &receiver);
void clearRewrites();
StringRef copyString(StringRef str) {
char *buf = StrAlloc.Allocate<char>(str.size());
std::memcpy(buf, str.data(), str.size());
return StringRef(buf, str.size());
}
StringRef copyString(StringRef str) { return str.copy(StrAlloc); }
StringRef copyString(const Twine &twine);
private:

View File

@ -183,7 +183,7 @@ void Commit::addInsert(SourceLocation OrigLoc, FileOffset Offs, StringRef text,
data.Kind = Act_Insert;
data.OrigLoc = OrigLoc;
data.Offset = Offs;
data.Text = copyString(text);
data.Text = text.copy(StrAlloc);
data.BeforePrev = beforePreviousInsertions;
CachedEdits.push_back(data);
}