Merge branch 'cleanup_esm3_readers_cache' into 'master'

Remove stateless encoder from ReadersCache

See merge request OpenMW/openmw!3823
ini_importer_tests
psi29a 11 months ago
commit c9489bad9b

@ -64,11 +64,12 @@ namespace MWWorld
}
case ESM::Format::Tes4:
{
ESM4::Reader readerESM4(std::move(stream), filepath,
MWBase::Environment::get().getResourceSystem()->getVFS(), mReaders.getStatelessEncoder());
readerESM4.setModIndex(index);
readerESM4.updateModIndices(mNameToIndex);
mStore.loadESM4(readerESM4);
ESM4::Reader reader(std::move(stream), filepath,
MWBase::Environment::get().getResourceSystem()->getVFS(),
mEncoder != nullptr ? &mEncoder->getStatelessEncoder() : nullptr);
reader.setModIndex(index);
reader.updateModIndices(mNameToIndex);
mStore.loadESM4(reader);
break;
}
}

@ -274,8 +274,6 @@ namespace MWWorld
const std::vector<std::string>& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener)
{
mContentFiles = contentFiles;
if (encoder)
mReaders.setStatelessEncoder(encoder->getStatelessEncoder());
mESMVersions.resize(mContentFiles.size(), -1);
loadContentFiles(fileCollections, contentFiles, encoder, listener);

@ -9,8 +9,6 @@
#include <optional>
#include <string>
#include <components/to_utf8/to_utf8.hpp>
namespace ESM
{
class ReadersCache
@ -57,23 +55,13 @@ namespace ESM
BusyItem get(std::size_t index);
void setStatelessEncoder(const ToUTF8::StatelessUtf8Encoder& statelessEncoderPtr)
{
mStatelessEncoder.emplace(statelessEncoderPtr);
}
const ToUTF8::StatelessUtf8Encoder* getStatelessEncoder()
{
return mStatelessEncoder.has_value() ? &mStatelessEncoder.value() : nullptr;
}
private:
const std::size_t mCapacity;
std::map<std::size_t, std::list<Item>::iterator> mIndex;
std::list<Item> mBusyItems;
std::list<Item> mFreeItems;
std::list<Item> mClosedItems;
std::optional<ToUTF8::StatelessUtf8Encoder> mStatelessEncoder;
inline void closeExtraReaders();
inline void releaseItem(std::list<Item>::iterator it) noexcept;

Loading…
Cancel
Save