aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-12 18:53:43 +0000
committerChris Lattner <sabre@nondot.org>2007-02-12 18:53:43 +0000
commitdd8cec59fc6b3b3a97932c56b6e6aa8c6453df39 (patch)
treef3bafc8afbd59018d83daf5e443aa8f080a018c9 /lib/Bytecode/Reader/Reader.cpp
parent042ad36871d67a2db48bf41a8dbde3a5676fc96f (diff)
avoid creating a temporary string when reading the symbol table for a
module. This speeds up the bcreader 11%. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp30
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 0f0cf5e6cd..376c0702a3 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/lib/Bytecode/Reader/Reader.cpp
@@ -132,6 +132,17 @@ inline std::string BytecodeReader::read_str() {
return std::string((char*)OldAt, Size);
}
+void BytecodeReader::read_str(SmallVectorImpl<char> &StrData) {
+ StrData.clear();
+ unsigned Size = read_vbr_uint();
+ const unsigned char *OldAt = At;
+ At += Size;
+ if (At > BlockEnd) // Size invalid?
+ error("Ran out of data reading a string!");
+ StrData.append(OldAt, At);
+}
+
+
/// Read an arbitrary block of data
inline void BytecodeReader::read_data(void *Ptr, void *End) {
unsigned char *Start = (unsigned char *)Ptr;
@@ -943,6 +954,8 @@ void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
E = CurrentFunction->end(); I != E; ++I)
BBMap.push_back(I);
+ SmallVector<char, 32> NameStr;
+
while (moreInBlock()) {
// Symtab block header: [num entries][type id number]
unsigned NumEntries = read_vbr_uint();
@@ -951,19 +964,22 @@ void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
for (unsigned i = 0; i != NumEntries; ++i) {
// Symtab entry: [def slot #][name]
unsigned slot = read_vbr_uint();
- std::string Name = read_str();
+ read_str(NameStr);
Value *V = 0;
if (Typ == LabelTySlot) {
- if (slot < BBMap.size())
- V = BBMap[slot];
+ V = (slot < BBMap.size()) ? BBMap[slot] : 0;
} else {
- V = getValue(Typ, slot, false); // Find mapping...
+ V = getValue(Typ, slot, false); // Find mapping.
}
- if (Handler) Handler->handleSymbolTableValue(Typ, slot, Name);
+ if (Handler) Handler->handleSymbolTableValue(Typ, slot,
+ &NameStr[0], NameStr.size());
if (V == 0)
- error("Failed value look-up for name '" + Name + "', type #" +
+ error("Failed value look-up for name '" +
+ std::string(NameStr.begin(), NameStr.end()) + "', type #" +
utostr(Typ) + " slot #" + utostr(slot));
- V->setName(Name);
+ V->setName(&NameStr[0], NameStr.size());
+
+ NameStr.clear();
}
}
checkPastBlockEnd("Symbol Table");