summaryrefslogtreecommitdiff
path: root/include/llvm/Bitcode/BitstreamReader.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-07 02:56:46 +0000
committerChris Lattner <sabre@nondot.org>2009-04-07 02:56:46 +0000
commitae7dd8004eb286039ee1eb1a35ddb1ff4eafe460 (patch)
tree30b9a036ce62a240168aa7731811e43f13c0238f /include/llvm/Bitcode/BitstreamReader.h
parent683b08cf7c47dd3ec1d898efa02ec0780b080de5 (diff)
downloadllvm-ae7dd8004eb286039ee1eb1a35ddb1ff4eafe460.tar.gz
llvm-ae7dd8004eb286039ee1eb1a35ddb1ff4eafe460.tar.bz2
llvm-ae7dd8004eb286039ee1eb1a35ddb1ff4eafe460.tar.xz
Add an API for the bitstream reader to read blobs and return
them by reference, instead of packing each byte into a smallvector. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@68486 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Bitcode/BitstreamReader.h')
-rw-r--r--include/llvm/Bitcode/BitstreamReader.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h
index fe51ade4cb..d64c0dc2ac 100644
--- a/include/llvm/Bitcode/BitstreamReader.h
+++ b/include/llvm/Bitcode/BitstreamReader.h
@@ -371,7 +371,8 @@ public:
return CurAbbrevs[AbbrevNo];
}
- unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals) {
+ unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
+ const char **BlobStart = 0, unsigned *BlobLen = 0) {
if (AbbrevID == bitc::UNABBREV_RECORD) {
unsigned Code = ReadVBR(6);
unsigned NumElts = ReadVBR(6);
@@ -413,9 +414,15 @@ public:
break;
}
- // Otherwise, read the number of bytes.
- for (; NumElts; ++NextChar, --NumElts)
- Vals.push_back(*NextChar);
+ // Otherwise, read the number of bytes. If we can return a reference to
+ // the data, do so to avoid copying it.
+ if (BlobStart) {
+ *BlobStart = (const char*)NextChar;
+ *BlobLen = NumElts;
+ } else {
+ for (; NumElts; ++NextChar, --NumElts)
+ Vals.push_back(*NextChar);
+ }
// Skip over tail padding.
NextChar = NewEnd;
} else {
@@ -428,6 +435,12 @@ public:
return Code;
}
+ unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,
+ const char *&BlobStart, unsigned &BlobLen) {
+ return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen);
+ }
+
+
//===--------------------------------------------------------------------===//
// Abbrev Processing
//===--------------------------------------------------------------------===//