1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 10:42:39 +01:00

[Bitcode] reserve in front of push_back loops. NFCI.

This commit is contained in:
Benjamin Kramer 2020-05-01 15:39:55 +02:00
parent 1d38c691e8
commit 906fd75443

View File

@ -214,6 +214,7 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID,
if (!MaybeNumElts)
return MaybeNumElts.takeError();
uint32_t NumElts = MaybeNumElts.get();
Vals.reserve(Vals.size() + NumElts);
for (unsigned i = 0; i != NumElts; ++i)
if (Expected<uint64_t> MaybeVal = ReadVBR64(6))
@ -263,6 +264,7 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID,
if (!MaybeNumElts)
return MaybeNumElts.takeError();
uint32_t NumElts = MaybeNumElts.get();
Vals.reserve(Vals.size() + NumElts);
// Get the element encoding.
if (i + 2 != e)
@ -334,8 +336,8 @@ Expected<unsigned> BitstreamCursor::readRecord(unsigned AbbrevID,
*Blob = StringRef(Ptr, NumElts);
} else {
// Otherwise, unpack into Vals with zero extension.
for (; NumElts; --NumElts)
Vals.push_back((unsigned char)*Ptr++);
auto *UPtr = reinterpret_cast<const unsigned char *>(Ptr);
Vals.append(UPtr, UPtr + NumElts);
}
}
@ -458,21 +460,15 @@ BitstreamCursor::ReadBlockInfoBlock(bool ReadBlockInfoNames) {
return None;
if (!ReadBlockInfoNames)
break; // Ignore name.
std::string Name;
for (unsigned i = 0, e = Record.size(); i != e; ++i)
Name += (char)Record[i];
CurBlockInfo->Name = Name;
CurBlockInfo->Name = std::string(Record.begin(), Record.end());
break;
}
case bitc::BLOCKINFO_CODE_SETRECORDNAME: {
if (!CurBlockInfo) return None;
if (!ReadBlockInfoNames)
break; // Ignore name.
std::string Name;
for (unsigned i = 1, e = Record.size(); i != e; ++i)
Name += (char)Record[i];
CurBlockInfo->RecordNames.push_back(std::make_pair((unsigned)Record[0],
Name));
CurBlockInfo->RecordNames.emplace_back(
(unsigned)Record[0], std::string(Record.begin() + 1, Record.end()));
break;
}
}