From 8c2a55264a9b5a3ad8deeeb7bb762a0c97d28b8f Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 12 Nov 2014 14:48:38 +0000 Subject: [PATCH] Reduce code duplication a bit. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221785 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Bitcode/BitstreamReader.h | 13 ++++--------- lib/Bitcode/Reader/BitcodeReader.cpp | 4 ++-- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/include/llvm/Bitcode/BitstreamReader.h b/include/llvm/Bitcode/BitstreamReader.h index e43f8e17fec..6258cecf7a8 100644 --- a/include/llvm/Bitcode/BitstreamReader.h +++ b/include/llvm/Bitcode/BitstreamReader.h @@ -199,19 +199,14 @@ class BitstreamCursor { public: - BitstreamCursor() : BitStream(nullptr), NextChar(0) {} + BitstreamCursor() { init(nullptr); } - explicit BitstreamCursor(BitstreamReader &R) : BitStream(&R) { - NextChar = 0; - CurWord = 0; - BitsInCurWord = 0; - CurCodeSize = 2; - } + explicit BitstreamCursor(BitstreamReader &R) { init(&R); } - void init(BitstreamReader &R) { + void init(BitstreamReader *R) { freeState(); - BitStream = &R; + BitStream = R; NextChar = 0; CurWord = 0; BitsInCurWord = 0; diff --git a/lib/Bitcode/Reader/BitcodeReader.cpp b/lib/Bitcode/Reader/BitcodeReader.cpp index 9e20ba628d3..713b6a3a4e5 100644 --- a/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/lib/Bitcode/Reader/BitcodeReader.cpp @@ -3417,7 +3417,7 @@ std::error_code BitcodeReader::InitStreamFromBuffer() { return Error(BitcodeError::InvalidBitcodeWrapperHeader); StreamFile.reset(new BitstreamReader(BufPtr, BufEnd)); - Stream.init(*StreamFile); + Stream.init(&*StreamFile); return std::error_code(); } @@ -3427,7 +3427,7 @@ std::error_code BitcodeReader::InitLazyStream() { // see it. StreamingMemoryObject *Bytes = new StreamingMemoryObject(LazyStreamer); StreamFile.reset(new BitstreamReader(Bytes)); - Stream.init(*StreamFile); + Stream.init(&*StreamFile); unsigned char buf[16]; if (Bytes->readBytes(0, 16, buf) == -1)