Merge branch 'master' of https://github.com/dolphin-emu/dolphin into dolphin-emu-master

This commit is contained in:
Nayla Hanegan 2024-10-23 14:29:49 -04:00
commit 4bd7d38a77
1243 changed files with 15939 additions and 15402 deletions

@ -1 +1 @@
Subproject commit f4ce3c9618e7ecfcdd238b17dad9a0b888f5de90
Subproject commit 8fae8ce254dfc1344527e05301e43f37dea2df80

View file

@ -3,6 +3,7 @@
#include <cassert>
#include <cstddef>
#include <map>
#include <utility>
namespace HyoutaUtilities {
template <typename T> class RangeSet {
@ -254,7 +255,31 @@ public:
return !(*this == other);
}
// Get free size and fragmentation ratio
std::pair<std::size_t, double> get_stats() const {
std::size_t free_total = 0;
if (begin() == end())
return {free_total, 1.0};
std::size_t largest_size = 0;
for (auto iter = begin(); iter != end(); ++iter) {
const std::size_t size = calc_size(iter.from(), iter.to());
if (size > largest_size)
largest_size = size;
free_total += size;
}
return {free_total, static_cast<double>(free_total - largest_size) / free_total};
}
private:
static std::size_t calc_size(T from, T to) {
if constexpr (std::is_pointer_v<T>) {
// For pointers we don't want pointer arithmetic here, else void* breaks.
return reinterpret_cast<std::size_t>(to) - reinterpret_cast<std::size_t>(from);
} else {
return static_cast<std::size_t>(to - from);
}
}
// Assumptions that can be made about the data:
// - Range are stored in the form [from, to[
// That is, the starting value is inclusive, and the end value is exclusive.

View file

@ -4,6 +4,7 @@
#include <cstddef>
#include <map>
#include <type_traits>
#include <utility>
namespace HyoutaUtilities {
// Like RangeSet, but additionally stores a map of the ranges sorted by their size, for quickly finding the largest or
@ -398,6 +399,16 @@ public:
return !(*this == other);
}
// Get free size and fragmentation ratio
std::pair<std::size_t, double> get_stats() const {
std::size_t free_total = 0;
if (begin() == end())
return {free_total, 1.0};
for (auto iter = begin(); iter != end(); ++iter)
free_total += calc_size(iter.from(), iter.to());
return {free_total, static_cast<double>(free_total - Sizes.begin()->first) / free_total};
}
private:
static SizeT calc_size(T from, T to) {
if constexpr (std::is_pointer_v<T>) {