mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
[llvm-tblgen] - Stop using std::string in RecordKeeper.
RecordKeeper::getDef() is a hot place, it shows up in profiling and it creates std::string instance for each search in RecordMap though RecordKeeper::RecordMap can use StringRef as a key instead to avoid that. Patch do that change. Differential revision: https://reviews.llvm.org/D40170 llvm-svn: 318822
This commit is contained in:
parent
36a95a03e9
commit
fb625e0c38
@ -1525,7 +1525,7 @@ struct MultiClass {
|
||||
};
|
||||
|
||||
class RecordKeeper {
|
||||
using RecordMap = std::map<std::string, std::unique_ptr<Record>>;
|
||||
using RecordMap = std::map<StringRef, std::unique_ptr<Record>>;
|
||||
RecordMap Classes, Defs;
|
||||
|
||||
public:
|
||||
|
@ -28,18 +28,17 @@ namespace {
|
||||
|
||||
class Tag {
|
||||
private:
|
||||
const std::string *Id;
|
||||
StringRef Id;
|
||||
SMLoc Loc;
|
||||
public:
|
||||
Tag(const std::string &Name, const SMLoc Location)
|
||||
: Id(&Name), Loc(Location) {}
|
||||
int operator<(const Tag &B) const { return *Id < *B.Id; }
|
||||
Tag(StringRef Name, const SMLoc Location) : Id(Name), Loc(Location) {}
|
||||
int operator<(const Tag &B) const { return Id < B.Id; }
|
||||
void emit(raw_ostream &OS) const {
|
||||
const MemoryBuffer *CurMB =
|
||||
SrcMgr.getMemoryBuffer(SrcMgr.FindBufferContainingLoc(Loc));
|
||||
auto BufferName = CurMB->getBufferIdentifier();
|
||||
std::pair<unsigned, unsigned> LineAndColumn = SrcMgr.getLineAndColumn(Loc);
|
||||
OS << *Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n";
|
||||
OS << Id << "\t" << BufferName << "\t" << LineAndColumn.first << "\n";
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user