summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-07-13 12:11:19 +0200
committerGitHub <noreply@github.com>2016-07-13 12:11:19 +0200
commitf4d2626d2bc7ba1980026e6b28d72ea9d54ddc29 (patch)
treefd1a84bc1b7d2faeb4a0e22dc1d8ca8c7c9608bd /Source/Core/DiscIO
parent3f9a98ddf2a77aa9ec2ed3d987cdf7aca25901b9 (diff)
parent9036b9d8e80aa72daf4d7258ba64aac0aa04733c (diff)
Merge pull request #4005 from EmptyChaos/blockcache-bug
SectorReader: Minor cache bias bug
Diffstat (limited to 'Source/Core/DiscIO')
-rw-r--r--Source/Core/DiscIO/Blob.cpp15
-rw-r--r--Source/Core/DiscIO/DriveBlob.cpp4
2 files changed, 11 insertions, 8 deletions
diff --git a/Source/Core/DiscIO/Blob.cpp b/Source/Core/DiscIO/Blob.cpp
index 32c559b6eb..a3d9d8deb8 100644
--- a/Source/Core/DiscIO/Blob.cpp
+++ b/Source/Core/DiscIO/Blob.cpp
@@ -57,12 +57,15 @@ SectorReader::Cache* SectorReader::GetEmptyCacheLine()
{
Cache* oldest = &m_cache[0];
// Find the Least Recently Used cache line to replace.
- for (auto& cache_entry : m_cache)
- {
- if (cache_entry.IsLessRecentlyUsedThan(*oldest))
- oldest = &cache_entry;
- cache_entry.ShiftLRU();
- }
+ std::for_each(m_cache.begin() + 1, m_cache.end(), [&](Cache& line) {
+ if (line.IsLessRecentlyUsedThan(*oldest))
+ {
+ oldest->ShiftLRU();
+ oldest = &line;
+ return;
+ }
+ line.ShiftLRU();
+ });
oldest->Reset();
return oldest;
}
diff --git a/Source/Core/DiscIO/DriveBlob.cpp b/Source/Core/DiscIO/DriveBlob.cpp
index f522923f33..5a4c5aa2f1 100644
--- a/Source/Core/DiscIO/DriveBlob.cpp
+++ b/Source/Core/DiscIO/DriveBlob.cpp
@@ -138,9 +138,9 @@ bool DriveReader::ReadMultipleAlignedBlocks(u64 block_num, u64 num_blocks, u8* o
#ifdef _WIN32
LARGE_INTEGER offset;
offset.QuadPart = GetSectorSize() * block_num;
- SetFilePointerEx(m_disc_handle, offset, nullptr, FILE_BEGIN);
DWORD bytes_read;
- if (!ReadFile(m_disc_handle, out_ptr, static_cast<DWORD>(GetSectorSize() * num_blocks),
+ if (!SetFilePointerEx(m_disc_handle, offset, nullptr, FILE_BEGIN) ||
+ !ReadFile(m_disc_handle, out_ptr, static_cast<DWORD>(GetSectorSize() * num_blocks),
&bytes_read, nullptr))
{
PanicAlertT("Disc Read Error");