Reduce a bit the size of getHT

Factoring common code parts outside of a template
is apparently a good practise to reduce code duplication
(and the size of openmw by around 0.5%),
and should improve a bit the performances,
since the whole `std::to_string` * 2 + string concatenation
dance results in quite a lot of code, preventing inlining on my machine.
dont-compose-content
jvoisin 4 years ago
parent ba3d66503f
commit 5aaac8e47e

@ -198,7 +198,7 @@ void ESMReader::skipHSubSize(int size)
{
skipHSub();
if (static_cast<int> (mCtx.leftSub) != size)
fail("skipHSubSize() mismatch");
reportSubSizeMismatch(mCtx.leftSub, size);
}
void ESMReader::skipHSubUntil(const char *name)

@ -134,11 +134,7 @@ public:
{
getSubHeader();
if (mCtx.leftSub != sizeof(X))
{
fail("getHT(): subrecord size mismatch,requested "
+ std::to_string(sizeof(X)) + ", got"
+ std::to_string(mCtx.leftSub));
}
reportSubSizeMismatch(sizeof(X), mCtx.leftSub);
getT(x);
}
@ -261,6 +257,13 @@ public:
size_t getFileSize() const { return mFileSize; }
private:
[[noreturn]] void reportSubSizeMismatch(size_t want, size_t got) {
fail("subrecord size mismatch, requested " +
std::to_string(want) +
", got" +
std::to_string(got));
}
void clearCtx();
Files::IStreamPtr mEsm;

Loading…
Cancel
Save