aboutsummaryrefslogtreecommitdiff
path: root/lib/Bytecode/Reader/ConstantReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2003-11-19 06:01:12 +0000
committerChris Lattner <sabre@nondot.org>2003-11-19 06:01:12 +0000
commit1c3673b238c8b016ee1137e39a44e06807e8ec44 (patch)
tree41fd21b019ccf2961cd8dd04cc49b8b2a905c733 /lib/Bytecode/Reader/ConstantReader.cpp
parentcc33d70a92866e615a0e1d5b97d9cd3e90e99115 (diff)
Minor speedup to do less linear time searches of information we already have.
speeds up disassembly of kc++ by .6s git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10079 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/ConstantReader.cpp')
-rw-r--r--lib/Bytecode/Reader/ConstantReader.cpp12
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/Bytecode/Reader/ConstantReader.cpp b/lib/Bytecode/Reader/ConstantReader.cpp
index b4553548e8..efc3f01c1e 100644
--- a/lib/Bytecode/Reader/ConstantReader.cpp
+++ b/lib/Bytecode/Reader/ConstantReader.cpp
@@ -168,13 +168,11 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
unsigned ArgValSlot, ArgTypeSlot;
if (read_vbr(Buf, EndBuf, ArgValSlot)) throw Error_readvbr;
if (read_vbr(Buf, EndBuf, ArgTypeSlot)) throw Error_readvbr;
- const Type *ArgTy = getType(ArgTypeSlot);
-
- BCR_TRACE(4, "CE Arg " << i << ": Type: '" << *ArgTy << "' slot: "
- << ArgValSlot << "\n");
+ BCR_TRACE(4, "CE Arg " << i << ": Type: '" << *getType(ArgTypeSlot)
+ << "' slot: " << ArgValSlot << "\n");
// Get the arg value from its slot if it exists, otherwise a placeholder
- ArgVec.push_back(getConstantValue(ArgTy, ArgValSlot));
+ ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot));
}
// Construct a ConstantExpr of the appropriate kind
@@ -245,12 +243,12 @@ Constant *BytecodeParser::parseConstantValue(const unsigned char *&Buf,
case Type::ArrayTyID: {
const ArrayType *AT = cast<ArrayType>(Ty);
unsigned NumElements = AT->getNumElements();
-
+ unsigned TypeSlot = getTypeSlot(AT->getElementType());
std::vector<Constant*> Elements;
while (NumElements--) { // Read all of the elements of the constant.
unsigned Slot;
if (read_vbr(Buf, EndBuf, Slot)) throw Error_readvbr;
- Elements.push_back(getConstantValue(AT->getElementType(), Slot));
+ Elements.push_back(getConstantValue(TypeSlot, Slot));
}
return ConstantArray::get(AT, Elements);
}