diff options
author | Lioncash <mathew1800@gmail.com> | 2019-07-24 13:14:47 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2019-08-30 01:28:57 +0200 |
commit | 785c4946ddf79c0c4454c003baa20cab6ebb63ca (patch) | |
tree | dddd0b62fd968b39b84ae72892e18ab4b214aa5a /src/core/hle | |
parent | kernel/vm_manager: Simplify some std::vector constructor calls (diff) | |
download | yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar.gz yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar.bz2 yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar.lz yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar.xz yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.tar.zst yuzu-785c4946ddf79c0c4454c003baa20cab6ebb63ca.zip |
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/vm_manager.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index 231e42baa..e86796ba5 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -757,19 +757,22 @@ void VMManager::MergeAdjacentVMA(VirtualMemoryArea& left, const VirtualMemoryAre // Always merge allocated memory blocks, even when they don't share the same backing block. if (left.type == VMAType::AllocatedMemoryBlock && (left.backing_block != right.backing_block || left.offset + left.size != right.offset)) { + const auto right_begin = right.backing_block->begin() + right.offset; + const auto right_end = right_begin + right.size; + // Check if we can save work. if (left.offset == 0 && left.size == left.backing_block->size()) { // Fast case: left is an entire backing block. - left.backing_block->insert(left.backing_block->end(), - right.backing_block->begin() + right.offset, - right.backing_block->begin() + right.offset + right.size); + left.backing_block->insert(left.backing_block->end(), right_begin, right_end); } else { + const auto left_begin = left.backing_block->begin() + left.offset; + const auto left_end = left_begin + left.size; + // Slow case: make a new memory block for left and right. auto new_memory = std::make_shared<PhysicalMemory>(); - new_memory->insert(new_memory->end(), left.backing_block->begin() + left.offset, - left.backing_block->begin() + left.offset + left.size); - new_memory->insert(new_memory->end(), right.backing_block->begin() + right.offset, - right.backing_block->begin() + right.offset + right.size); + new_memory->insert(new_memory->end(), left_begin, left_end); + new_memory->insert(new_memory->end(), right_begin, right_end); + left.backing_block = new_memory; left.offset = 0; } |