impr: Improve file reading performance if opening of files is slow
This commit is contained in:
parent
0a0c0c0d07
commit
060ff56f9d
2
lib/external/libwolv
vendored
2
lib/external/libwolv
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 213c0efc90a15a2034f744f64779bd097e5735a7
|
Subproject commit c24015b8f5b5e99bab18978a9d10f2e8c859f9b2
|
2
lib/external/pattern_language
vendored
2
lib/external/pattern_language
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 69a6330a6f0e557a1457aebfe671897954e6c6d9
|
Subproject commit 3599a304b368af608bd4da85a8853fa2f172d128
|
@ -204,7 +204,9 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this->m_fileStats = file.getFileInfo();
|
this->m_fileStats = file.getFileInfo();
|
||||||
this->m_sizeFile = wolv::io::File(this->m_path, wolv::io::File::Mode::Read);
|
this->m_sizeFile = file.clone();
|
||||||
|
|
||||||
|
this->m_files.emplace(std::this_thread::get_id(), std::move(file));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -214,15 +216,15 @@ namespace hex::plugin::builtin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
wolv::io::File& FileProvider::getFile() {
|
wolv::io::File& FileProvider::getFile() {
|
||||||
std::scoped_lock lock(this->m_fileAccessMutex);
|
|
||||||
|
|
||||||
if (this->m_files.size() > 5)
|
auto threadId = std::this_thread::get_id();
|
||||||
this->m_files.clear();
|
if (!this->m_files.contains(threadId)) {
|
||||||
|
std::scoped_lock lock(this->m_fileAccessMutex);
|
||||||
|
if (!this->m_files.contains(threadId))
|
||||||
|
this->m_files.emplace(threadId, this->m_sizeFile.clone());
|
||||||
|
}
|
||||||
|
|
||||||
if (!this->m_files.contains(std::this_thread::get_id()))
|
return this->m_files[threadId];
|
||||||
this->m_files.emplace(std::this_thread::get_id(), wolv::io::File(this->m_path, wolv::io::File::Mode::Read));
|
|
||||||
|
|
||||||
return this->m_files[std::this_thread::get_id()];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileProvider::loadSettings(const nlohmann::json &settings) {
|
void FileProvider::loadSettings(const nlohmann::json &settings) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user