From 085b388a7aaa37663cec84d06a0c2cb674bee73a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Fri, 5 Apr 2019 20:22:53 -0400 Subject: video_core/memory_manager: Make FindFreeRegion() a const member function This doesn't modify internal state, so it can be made a const member function. --- src/video_core/memory_manager.cpp | 19 ++++++++++--------- src/video_core/memory_manager.h | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index 124a3c6d2..11b1d022a 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -77,16 +77,17 @@ GPUVAddr MemoryManager::UnmapBuffer(GPUVAddr gpu_addr, u64 size) { return gpu_addr; } -GPUVAddr MemoryManager::FindFreeRegion(GPUVAddr region_start, u64 size) { +GPUVAddr MemoryManager::FindFreeRegion(GPUVAddr region_start, u64 size) const { // Find the first Free VMA. - const VMAHandle vma_handle{std::find_if(vma_map.begin(), vma_map.end(), [&](const auto& vma) { - if (vma.second.type != VirtualMemoryArea::Type::Unmapped) { - return false; - } - - const VAddr vma_end{vma.second.base + vma.second.size}; - return vma_end > region_start && vma_end >= region_start + size; - })}; + const VMAHandle vma_handle{ + std::find_if(vma_map.begin(), vma_map.end(), [region_start, size](const auto& vma) { + if (vma.second.type != VirtualMemoryArea::Type::Unmapped) { + return false; + } + + const VAddr vma_end{vma.second.base + vma.second.size}; + return vma_end > region_start && vma_end >= region_start + size; + })}; if (vma_handle == vma_map.end()) { return {}; diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index c3b4d7ae7..d75c1c5c0 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h @@ -127,7 +127,7 @@ private: void UpdatePageTableForVMA(const VirtualMemoryArea& vma); /// Finds a free (unmapped region) of the specified size starting at the specified address. - GPUVAddr FindFreeRegion(GPUVAddr region_start, u64 size); + GPUVAddr FindFreeRegion(GPUVAddr region_start, u64 size) const; private: static constexpr u64 page_bits{16}; -- cgit v1.2.3