diff options
| author | bunnei <bunneidev@gmail.com> | 2020-05-24 00:32:44 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-24 00:32:44 -0400 |
| commit | 6d46de49c3d9dff028365b48778c40bb20c8d748 (patch) | |
| tree | de5ce0182bea7f3e16a8626df5b0ba4b2541ad02 /src/video_core/buffer_cache/map_interval.cpp | |
| parent | 4234de3fd7cceb5f08782873178fee77a950e4c2 (diff) | |
| parent | 9223dc7a10ed41a8fc644195fb573175ccf4cb4e (diff) | |
Merge pull request #3975 from ReinUsesLisp/fast-bufcache
buffer_cache: Replace boost::icl::interval_map with boost::intrusive::set
Diffstat (limited to 'src/video_core/buffer_cache/map_interval.cpp')
| -rw-r--r-- | src/video_core/buffer_cache/map_interval.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/video_core/buffer_cache/map_interval.cpp b/src/video_core/buffer_cache/map_interval.cpp new file mode 100644 index 0000000000..62587e18a1 --- /dev/null +++ b/src/video_core/buffer_cache/map_interval.cpp @@ -0,0 +1,33 @@ +// Copyright 2020 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <algorithm> +#include <array> +#include <cstddef> +#include <memory> + +#include "video_core/buffer_cache/map_interval.h" + +namespace VideoCommon { + +MapIntervalAllocator::MapIntervalAllocator() { + FillFreeList(first_chunk); +} + +MapIntervalAllocator::~MapIntervalAllocator() = default; + +void MapIntervalAllocator::AllocateNewChunk() { + *new_chunk = std::make_unique<Chunk>(); + FillFreeList(**new_chunk); + new_chunk = &(*new_chunk)->next; +} + +void MapIntervalAllocator::FillFreeList(Chunk& chunk) { + const std::size_t old_size = free_list.size(); + free_list.resize(old_size + chunk.data.size()); + std::transform(chunk.data.rbegin(), chunk.data.rend(), free_list.begin() + old_size, + [](MapInterval& interval) { return &interval; }); +} + +} // namespace VideoCommon |
