mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-30 00:31:19 +00:00
Fix a heinous inefficiency introduced in r149918, wherein reading each byte of a
BLOB (i.e., large, performance intensive data) in a bitcode file was switched to invoking one virtual method call per byte read. Now we do one virtual call per BLOB. llvm-svn: 173065
This commit is contained in:
1 parent
3e3194f4ec
commit
1aeca1e806
2 files changed
+8
-15
No files matched your search
@@ -255,18 +255,17 @@ unsigned BitstreamCursor::readRecord(unsigned AbbrevID,
|
||||
break;
|
||||
}
|
||||
|
||||
// Otherwise, read the number of bytes. If we can return a reference to
|
||||
// the data, do so to avoid copying it.
|
||||
// Otherwise, inform the streamer that we need these bytes in memory.
|
||||
const char *Ptr = (const char*)
|
||||
BitStream->getBitcodeBytes().getPointer(CurBitPos/8, NumElts);
|
||||
|
||||
// If we can return a reference to the data, do so to avoid copying it.
|
||||
if (Blob) {
|
||||
*Blob =
|
||||
StringRef((const char*)BitStream->getBitcodeBytes().getPointer(
|
||||
CurBitPos/8, NumElts),
|
||||
NumElts);
|
||||
*Blob = StringRef(Ptr, NumElts);
|
||||
} else {
|
||||
// FIXME: This is a brutally inefficient way to do this. Why isn't this
|
||||
// just using getPointer?
|
||||
// Otherwise, unpack into Vals with zero extension.
|
||||
for (; NumElts; --NumElts)
|
||||
Vals.push_back(Read(8));
|
||||
Vals.push_back((unsigned char)*Ptr++);
|
||||
}
|
||||
// Skip over tail padding.
|
||||
JumpToBit(NewEnd);
|
||||
|
||||
Reference in new issue
Block a user