1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-30 08:15:37 +00:00

Remove stateless encoder from ReadersCache

It was added by https://gitlab.com/OpenMW/openmw/-/merge_requests/2804 without a
good reason. There is already encoder available in the used context.
This commit is contained in:
elsid 2024-01-29 11:01:52 +01:00
parent be6d063b94
commit f9b69623d3
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625
3 changed files with 7 additions and 20 deletions

View file

@ -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;
}
}

View file

@ -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);

View file

@ -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;