diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-01-17 15:31:23 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-01-17 15:31:23 +1100 |
| commit | 1f5249de6f7e81aa6ff2586e386f526676e67c81 (patch) | |
| tree | 5fcc9737e71b3b6b20b7156ea4e759b558f732a3 /src/util/include/lru_cache.hpp | |
| parent | 08d16e858075e66df1bae3fea9d955e1b6cb73a9 (diff) | |
| download | tangara-fw-1f5249de6f7e81aa6ff2586e386f526676e67c81.tar.gz | |
shift some long-lived allocs into spi ram
Diffstat (limited to 'src/util/include/lru_cache.hpp')
| -rw-r--r-- | src/util/include/lru_cache.hpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/util/include/lru_cache.hpp b/src/util/include/lru_cache.hpp index 8f955a07..41293901 100644 --- a/src/util/include/lru_cache.hpp +++ b/src/util/include/lru_cache.hpp @@ -13,6 +13,7 @@ #include <optional> #include <unordered_map> #include <utility> +#include "memory_resource.hpp" namespace util { @@ -25,7 +26,9 @@ namespace util { template <int Size, typename K, typename V> class LruCache { public: - LruCache() : entries_(), key_to_it_() {} + LruCache() + : entries_(&memory::kSpiRamResource), + key_to_it_(&memory::kSpiRamResource) {} auto Put(K key, V val) -> void { if (key_to_it_.contains(key)) { @@ -62,8 +65,8 @@ class LruCache { } private: - std::list<std::pair<K, V>> entries_; - std::unordered_map<K, decltype(entries_.begin())> key_to_it_; + std::pmr::list<std::pair<K, V>> entries_; + std::pmr::unordered_map<K, decltype(entries_.begin())> key_to_it_; }; } // namespace util |
