mirror of
https://github.com/KytyPS5/KytyPS5.git
synced 2026-10-28 13:56:59 +01:00
graphics: reuse range-set nodes when merging additions
Co-authored-by: Majed-allababedi <60163390+Majed-allababedi@users.noreply.github.com>
This commit is contained in:
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#include <iterator>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
namespace Libs::Graphics {
|
namespace Libs::Graphics {
|
||||||
@@ -17,14 +18,19 @@ public:
|
|||||||
if (it != m_ranges.begin() && std::prev(it)->second >= address) {
|
if (it != m_ranges.begin() && std::prev(it)->second >= address) {
|
||||||
it = std::prev(it);
|
it = std::prev(it);
|
||||||
}
|
}
|
||||||
uint64_t begin = address;
|
if (it == m_ranges.end() || it->first > address) {
|
||||||
uint64_t last = end;
|
it = m_ranges.emplace_hint(it, address, end);
|
||||||
while (it != m_ranges.end() && it->first <= last) {
|
} else {
|
||||||
begin = std::min(begin, it->first);
|
if (it->second >= end) {
|
||||||
last = std::max(last, it->second);
|
return;
|
||||||
it = m_ranges.erase(it);
|
}
|
||||||
|
it->second = end;
|
||||||
|
}
|
||||||
|
auto next = std::next(it);
|
||||||
|
while (next != m_ranges.end() && next->first <= it->second) {
|
||||||
|
it->second = std::max(it->second, next->second);
|
||||||
|
next = m_ranges.erase(next);
|
||||||
}
|
}
|
||||||
m_ranges.emplace(begin, last);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Subtract(uint64_t address, uint64_t size) {
|
void Subtract(uint64_t address, uint64_t size) {
|
||||||
|
|||||||
Reference in New Issue
Block a user